Solved: How do I change the primary key of a table?

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

Solved: How do I change the primary key of a table?

Post by mister_v »

I would like to change the primary key of a table,
But don't know how to do that.

Do I have to drop the table and recreate it?
I don't want to do that.
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: How do I change the primary key of a table?

Post by chris »

You can use the following command:

Code: Select all

ALTER TABLE table DROP PRIMARY KEY, ADD PRIMARY KEY (col_a, col_b);
Post Reply