Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alter redshift column encoding in place?

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 ?

like image 948
Hello lad Avatar asked Dec 11 '15 08:12

Hello lad


People also ask

How do you change the encoding of a column in Redshift?

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.

Can we alter column datatype in Redshift?

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.

Can we change distribution key in Redshift?

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.

How do I change the distribution style in Redshift?

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.


1 Answers

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

like image 193
Neil Stoneman Avatar answered Oct 22 '22 12:10

Neil Stoneman