开发者

How do I drop a primary key in MySQL?

开发者 https://www.devze.com 2022-12-18 22:44 出处:网络
I have a primary key name idnumber. how can I remove its primary k开发者_运维技巧ey in mysqlThis should work for you, but are you sure you want to drop the primary key?

I have a primary key name idnumber. how can I remove its primary k开发者_运维技巧ey in mysql


This should work for you, but are you sure you want to drop the primary key?


ALTER TABLE tablename DROP PRIMARY KEY;


Help on alter table syntax here

Why would you want to drop the the primary key? If you created it by mistake then you can change it by

alter table T drop primary key, add primary key (C);

Where T is the table name and C is the column containing the correct primary key


You'd need to drop and create a new primary key if you currently have it on AUTOINCREMENT, something like this:

ALTER TABLE table DROP PRIMARY KEY, ADD PRIMARY KEY(your_column);
0

精彩评论

暂无评论...
验证码 换一张
取 消