change primary key

Post Reply
Posts: 193
Joined: Thu Mar 04, 2010 9:19 pm

change primary key

Post by mister_v »


I need to change the primary key of a table.
I need to add a column,
how do I do this ?
Site Admin
Posts: 200
Joined: Mon Jul 21, 2008 9:52 am

Re: change primary key

Post 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);
Post Reply