Mysql Modify the method of adding a primary key: Execute the [ALTER TABLE `test2` DROP PRIMARY KEY, ADD PRIMARY KEY (`id`);] statement to modify the primary key.
Add table fields
(Recommended tutorial: mysql video tutorial)
alter table table1 add transactor varchar(10) not Null; alter table table1 add id int unsigned not Null auto_increment primary key
Modify the primary key
ALTER TABLE `test2` DROP PRIMARY KEY ,ADD PRIMARY KEY ( `id` )
Increase index
ALTER TABLE `test2` ADD INDEX ( `id` ) ALTER TABLE `category ` MODIFY COLUMN `id` int(11) NOT NULL AUTO_INCREMENT FIRST ,ADD PRIMARY KEY (`id`);
Related recommendations: mysql tutorial
The above is the detailed content of How to modify and add primary key in mysql. For more information, please follow other related articles on the PHP Chinese website!