How to add a sort key to an existing table in AWS Redshift

后端 未结 7 867
孤街浪徒
孤街浪徒 2021-01-01 09:24

In AWS Redshift, I want to add a sort key to a table that is already created. Is there any command which can add a column and use it as sort key?

7条回答
  •  甜味超标
    2021-01-01 10:01

    Catching this query a bit late.
    I find that using 1=1 the best way to create and replicate data into another table in redshift eg: CREATE TABLE NEWTABLE AS SELECT * FROM OLDTABLE WHERE 1=1;

    then you can drop the OLDTABLE after verifying that the data has been copied

    (if you replace 1=1 with 1=2, it copies only the structure - which is good for creating staging tables)

提交回复
热议问题