mysql重新生成主键,使之连续。
让mysql表主键重新从1开始,保留原有数据。
sql如下:
alter table yourTableName drop yourPrimaryKeyName;
alter table yourTableName add yourPrimaryKeyName int not null primary key auto_increment first;
第一句是删掉那一列,第二句是重新添加那一列,并设置相关属性。例如:
alter table person drop id;
alter table person add id int not null primary key auto_increment first;