Reset your MySQL Table Auto Increment Value

Recently,I created tables using auto increment number as the Primary Key. As name say, the number will increase every time I insert new record into the table. At some point I wanted to delete the whole dummy data I inserted.

ALTER TABLE tablename AUTO_INCREMENT = value;


eg.
If I had a items table and I created a few new items and then deleted them, to set the auto increment value back to ‘100′ i would simply:

ALTER TABLE items AUTO_INCREMENT = 100;

Comments

Can you tell me how to reset the auto increment of all the tables in a database at a time
Anonymous said…
nice post, but no need to get the maximum values , it will set automatically you can get it from here

http://webobserve.blogspot.com/2011/02/reset-mysql-table-autoincrement.html

Popular posts from this blog

How do I Use the Linux Top Command?

IOPS measurement