How do I drop a primary key in MySQL?
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);
精彩评论