In mysql, the statement to delete the primary key is "Alter table tb drop primary key;"; the Alter table statement is used to modify the structure of the table, and drop is used to indicate deletion. If the columns in the table have dynamic growth attributes , you need to delete the auto-increment first before you can delete the primary key.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
1) If the primary key id is not automatically incremented
The syntax for deleting the primary key is as follows:
Alter table tb drop primary key;//删除主建
##(2) If the primary key id is automatically incremented
The syntax for deleting a primary key is as follows:Alter table tb change id id int(10);//删除自增长 Alter table tb drop primary key;//删除主建Extended knowledge:
Alter table tb add primary key(id);(2) If the primary key id is automatically incremented
Alter table tb add primary key(id); Alter table tb change id id int(10) not null auto_increment;Recommended learning:
The above is the detailed content of What is the statement to delete primary key in mysql. For more information, please follow other related articles on the PHP Chinese website!