Is there a way to add/alter table column encoding on the original table without creating a new table and select all content from old table into new table ?
With the new ALTER TABLE <tbl> ALTER COLUMN <col> ENCODE <enc> command, users can dynamically change Redshift table compression encodings. Redshift will take care of adjusting data compression behind the scenes and the table remains available for users to query.
You can't alter a column to the same or different encoding type multiple times in a single command. You can't alter a column to the same encoding as currently defined for the column. You can't alter the encoding for a column in a table with an interleaved sortkey.
You can then use the ALTER TABLE ALTER DISTKEY command to add or modify the distribution key of a table, without impacting concurrent read or write queries. When you specify the appropriate distribution key for a table, Amazon Redshift places a similar number of rows on each node when loading data into that table.
As mentioned earlier, you cannot change the Redshift table distribution using alter table column. You have to redistribute the table data using CREATE TABLE AS command with new distribution style. For example, consider below CTAS example to redistribute the table data in Redshift.
Yes - this is now a supported option as of 20th Oct 2020, see AWS docs :
ALTER TABLE table_name
{
| ALTER COLUMN column_name ENCODE new_encode_type
https://aws.amazon.com/about-aws/whats-new/2020/10/amazon-redshift-supports-modifying-column-comprression-encodings-to-optimize-storage-utilization-query-performance/
https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With