I have two tables that I want to combine that are from the same data source, but my understanding is that the column order matters when inserting for Redshift, and they're not ordered in the same way.
So I have tables X and Y, like this:
Table X:
- column_a
- column_b
- column_c
- column_d
Table Y:
- column_c
- column_a
- column_b
I want to add the data from table X into table Y where their names/types match, and it doesn't matter that I'll lose column d. I've been trying to use pg_get_cols
to use a list of the column names from table Y to do the select from table X, but this answer makes me think that won't be possible.
I have about 200-300 table pairs to combine like this, so I'm looking for a solution to avoid having to write out the columns manually that many times!
Thanks