Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Defining the Primary Key

Status
Not open for further replies.

luds

Programmer
Jul 15, 2003
162
GB
Hi,
I created my mysql db, but then decided that I didn't want the primary key field.
Can someone tell me the command to make another field the primary key, please?

Thanks
luds
 
Luds,

First, get rid of the unwanted PK:
ALTER TABLE <tablename> DROP PRIMARY KEY;

Next, create the new PK:
ALTER TABLE <TABLENAME> ADD PRIMERY KEY (pk-col-name);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top