Bex
Bex

Reputation: 103

CREATE TABLE...LIKE not preserving primary keys in Redshift

I'm creating a copy of a table using the CREATE TABLE... LIKE statement in Redshift, and the copy is working, but primary key is not being preserved.

CREATE TABLE new_table (LIKE orig_table);

Am I missing a parameter that should be specified to ensure this works?

Thanks

Upvotes: 0

Views: 886

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175596

From CREATE TABLE

Tables created with the LIKE option don't inherit primary and foreign key constraints. Distribution style, sort keys, BACKUP, and NULL properties are inherited by LIKE tables, but you can't explicitly set them in the CREATE TABLE ... LIKE statement.

Upvotes: 2

Related Questions