HOWTO: Reset your MySQL Table Auto Increment Value

Something I seem to do quite regularly at the moment is resetting the auto increment value for a table in a MySQL database.

Really easy to do but also very easy to forget the syntax:

ALTER TABLE tablename AUTO_INCREMENT = value;

For example
If I had a products table and I created a few new products and then deleted them, to set the auto increment value back to ‘53′ i would simply:

ALTER TABLE products AUTO_INCREMENT = 53;

Tags: ,

Responses

There has been 1 response to HOWTO: Reset your MySQL Table Auto Increment Value.

  1. thanks..

Leave a Reply

Commenting rules

  • Try to keep your comments as relevant as possible.
  • No HTML/JavaScript/BBcode.
  • Don't be abusive: No racism, homophobia or any other nastiness.
  • Feel free to express your opinion, but do so in an eloquent way.

If you do not respect these rules your comments may be edited or even deleted.