Page 1 of 1

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

Posted: Sun Nov 22, 2015 1:57 pm
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.

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

Posted: Sun Nov 22, 2015 4:50 pm
by chris
You can use the following command:

Code: Select all

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