I have a table "MY_TABLE" in Snowflake that I would like to add an identity column to. I tried
ALTER TABLE "MY_TABLE"
ADD COLUMN primary_key int IDENTITY(1,1);
But this returns
SQL compilation error: Cannot add column 'PRIMARY_KEY' with non-constant default to non-empty table 'MY_TABLE'.
Is this just not possible in snowflake?
To try to get around this limitation, I tried to create a temp version of the table
CREATE OR REPLACE TABLE "MY_TABLE_TEMP" LIKE "MY_TABLE"
ALTER TABLE "MY_TABLE_TEMP" ADD COLUMN primary_key int IDENTITY(1,1)
INSERT INTO "MY_TABLE_TEMP"
SELECT * FROM "MY_TABLE";
But now I get the error
SQL compilation error: Insert value list does not match column list expecting <x+1> but got <x>
Which sort of makes sense, since I am not passing the primary key. At this point it seems like I may have to manually enter the list of x (which is a very high number) of column names into the sql query, so I am wondering if I am just doing this all wrong. Has anyone else run into a similar issue?