重置MySQL数据库表中的id

在我们的开发过程中,难免在做测试的时候会生成一些杂乱无章的SQL主键数据,当我们想要把主键id的数据重置,又不想把表中的数据全部删除的时候可以使用以下的方法:
执行以下的SQL语句可以重置数据库表中的id:

alter table 你的表名字 drop 你的表的主键;
alter table 你的表的名字 add 你的表的主键 int not null primary key auto_increment first;
alter table tb_details drop id;
alter table tb_details add id int not null primary key auto_increment first;

猜你喜欢

转载自blog.csdn.net/qq_44739706/article/details/114010046