1,删除原有主键:
ALTER TABLE `表名` DROP `id`;
2,添加新主键字段:
ALTER TABLE `表名` ADD `id` MEDIUMINT( 8 ) NOT NULL FIRST;
3,设置新主键:
ALTER TABLE `表名` MODIFY COLUMN `id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);
时间: 2024-10-14 10:34:01
1,删除原有主键:
ALTER TABLE `表名` DROP `id`;
2,添加新主键字段:
ALTER TABLE `表名` ADD `id` MEDIUMINT( 8 ) NOT NULL FIRST;
3,设置新主键:
ALTER TABLE `表名` MODIFY COLUMN `id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT,ADD PRIMARY KEY(id);