?方法一:原來的id取消自增和主鍵,只用于表格的排序。
新插入一個(gè)id2,自然會(huì)根據(jù)自增重新排列。刪除id,id2改id即可。
alter table 你的表名字 drop 你的表的主鍵;
alter table 你的表的名字 add 你的表的主鍵 int not null primary key auto_increment first;
alter table table_name drop id;
alter table table_name add id int not null primary key auto_increment first;
使用這種方法不影響表中數(shù)據(jù),從1遞增開始遞增
方法二:清空表,并重置id
truncate table table_name;
一次性刪除所有數(shù)據(jù),不可恢復(fù),無法回滾?
方法三:文章來源:http://www.zghlxwxcb.cn/news/detail-524060.html
delete from table_name;
alter table table_name auto_increment= 1;
方法四:文章來源地址http://www.zghlxwxcb.cn/news/detail-524060.html
ALTER TABLE table_name AUTO_INCREMENT = 1;
到了這里,關(guān)于【MySql】如何重置MySQL數(shù)據(jù)庫表中的id的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!