有時需要對mysql中設為auto_increment發的字段進行重置,因此總結了一下,大概有三種方式可以做到:
1、直接重置autoIncrement的值
ALTER TABLE table_name AUTO_INCREMENT = 1;
2、通過truncate table 完成
TRUNCATE TABLE table_name;
3、刪除表,然后重建表
DROP TABLE table_name;
CREATE TABLE table_name { ... };