snowflake-cloud-data-platform

How to alter primary key in table for snowflake?


I created a table with a primary key. I would like to alter a primary key.

I thought using Alter Table command is the solution, but not successful.

ALTER TABLE "tablename" ALTER PRIMARY KEY (col1,col2);

Could you please help me how to alter primary key using SQL statement?


Solution

  • You can add primary key constraint to a column but cannot alter an existing one.

    https://docs.snowflake.com/en/sql-reference/sql/create-table-constraint.html#out-of-line-unique-primary-foreign-key