I would like to copy a table in Redshift, such that I can preserve the existing column encodings while also adding DIST and SORT keys. Is there a simple repeatable way to do this?
Previously I have copied the table DDL (which doesn't have encodings), ANALYZED the table, manually typed in the column encodings, manually added DIST and SORT keys, created the new table, inserted the data, dropped the old, then altered the new. This is quite time consuming and prone to error.
Is there a better way?