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.
Solved: How do I change the primary key of a table?
-
mister_v
- Posts: 203
- Joined: Thu Mar 04, 2010 9:19 pm
-
chris
- Site Admin
- Posts: 216
- Joined: Mon Jul 21, 2008 9:52 am
Re: How do I change the primary key of a table?
You can use the following command:
Code: Select all
ALTER TABLE table DROP PRIMARY KEY, ADD PRIMARY KEY (col_a, col_b);