How to duplicate the schema of a Redshift table?

I am trying to duplicate a Redshift table including modifiers.

I tried using the CTAS operator and for some reason was unable to copy the modifiers like not null

create table public.my_table as (select * from public.my_old_table limit 1);

      

There is also no way to modify the table to add modifiers after the table has been created, which makes me think there is no way to duplicate the Redshift table schema, other than running the original create table statement against the CTAS statement.

+3


source to share


1 answer


According to the docs, you can do

CREATE TABLE my_table(LIKE my_old_table);

      



Edit: updated

+6


source







All Articles