mysql对自增id重新从1排序

使用mysql时,通常表中会有一个自增的id字段,但当我们想将表中的数据清空重新添加数据时,希望id重新从1开始计数,用以下两种方法均可:

 

方法一:

 

alter table tablename drop column id;
alter table tablename add id 
mediumint(8) not null primary key auto_increment first;

 

方法二:

 
alter table tablename auto_increment=0


你可能感兴趣的:(mysql,id,重置)