Alter diststyle in an existing table in redshift. Is it possible?

instead of dropping the table and recreating it as diststyle all i wanted to change the diststyle table diststyle , is this possible?

Thanks!

+9
source share
3 answers

The easiest way I've found is to use the following:

 BEGIN; CREATE TABLE mytable_tmp DISTSTYLE ALL -- You can also use DISTKEY(some_column) or DISTSTYLE EVEN AS SELECT * FROM mytable; DROP TABLE mytable; ALTER TABLE mytable_tmp RENAME TO mytable; COMMIT; 

This makes it easy to modify distkey or diststyle tables without even knowing which columns are in that table. You need to know the name of the table.

+9
source

Does not seem possible. It’s easier to recreate a table filled with the old one.

+1
source

You can use ALTER TABLE table_name ALTER DISTSTYLE KEY DISTKEY column_name followed by VACUUM SORT ONLY table_name

see documents for more details . the table will be redistributed into clusters:

When specifying a DISTSTYLE KEY, the data is distributed according to the values ​​in the DISTKEY column. For more information about DISTSTYLE, see ....

0
source

All Articles