MYSQL在不删除数据的情况下,重置主键自增id
2021-03-05 本文已影响0人
chuan_bai
SET @num := 0;
UPDATE table_name SET id = @num := (@num+1);
ALTER TABLE table_name AUTO_INCREMENT =1;
SET @num := 0;
UPDATE table_name SET id = @num := (@num+1);
ALTER TABLE table_name AUTO_INCREMENT =1;