View Single Post
  #1   IP: 49.87.51.222
Old 2015-01-14, 10:22 PM
Cedar Brook Cedar Brook is offline
初级会员
 
Join Date: 2008-08-23
Posts: 2
Cedar Brook 现在声名狼藉
Default 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
Reply With Quote