0

Can I reset the auto-increment index of a MySQL table so that it starts counting from zero again?

I want to reset id after 100th id to 0.

deluxion
  • 1
  • 2
  • This is impossible. Over. – u_mulder Feb 10 '17 at 12:41
  • If, through a trigger, you can execute `SELET COUNT(*) FROM yourtable`, get this result, and execute an auto_increment reset depending this result is greater or equal to 100, so it could be an alternative solution, but trigger are very likely to cause performance issues so not the best thing to do. – Anwar Feb 10 '17 at 12:45
  • Otherwise, if you use an object to query your database, you may want to attach a "listener" (simply, a script that is included on each insert) and do your checking here, but again it is not optimized. – Anwar Feb 10 '17 at 12:46
  • you can `TRUNCATE [table]` – Bugaloo Feb 10 '17 at 13:27

0 Answers0