Carson Myers
Carson Myers

Reputation: 38564

can I reset auto_increment field in mySql?

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?

Upvotes: 1

Views: 464

Answers (2)

joealba
joealba

Reputation: 740

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.7/en/truncate-table.html

Upvotes: 7

Devin Ceartas
Devin Ceartas

Reputation: 4829

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

Upvotes: 5

Related Questions