Mysql auto_increment recount of have id start at 1
- 2020-05-14 05:12:49
- OfStack
Method 1
delete from test;
alter table `test` auto_increment=1
(for good, you can set AUTO_INCREMENT to start with any value)
Tip: if there are a lot of table columns and data, the speed will be slow, such as more than 900,000 pieces, will be more than 10 minutes.
Method 2
truncate table test
(benefit, simplicity, AUTO_INCREMENT value start counting again)
In general, we can use the second one. Remember that all records are deleted completely.
delete from test;
alter table `test` auto_increment=1
(for good, you can set AUTO_INCREMENT to start with any value)
Tip: if there are a lot of table columns and data, the speed will be slow, such as more than 900,000 pieces, will be more than 10 minutes.
Method 2
truncate table test
(benefit, simplicity, AUTO_INCREMENT value start counting again)
In general, we can use the second one. Remember that all records are deleted completely.