tags:

views:

87

answers:

2

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

I deleted all the rows in the table--how can I reset that counter as well?

+3  A: 

Or just truncate the table instead of deleting the roles -- that drops and re-adds the table, resetting the autoincrement values in the process

Devin Ceartas
+5  A: 

To delete all rows from a MySQL table AND reset the auto_increment value, use the truncate command.

http://dev.mysql.com/doc/refman/5.0/en/truncate.html

joealba
In addition, truncate will be *significantly* faster than a delete.
Nazadus