Page 1 of 1

change primary key

Posted: Fri Feb 10, 2023 3:26 pm
by mister_v
hello,

I need to change the primary key of a table.
I need to add a column,
how do I do this ?

Re: change primary key

Posted: Fri Feb 10, 2023 3:29 pm
by chris
You first have to drop the current primary key,
and after create a new.
Best is to do it in 1 SQL alter statement.

Code: Select all

ALTER TABLE table_name DROP primary key, ADD primary key(k1, k2, k3);