Reseting auto_increment value on MySQL table

30 08 2006

After deleting every row from a table with an auto_increment column, the auto_increment value remains the same, so each insert after that does not start on 1, but on whatever it left off. To reset it:

ALTER TABLE myTable AUTO_INCREMENT=0;

Obviously, using this method you can set it to any value you wish. If the table contains a row with that auto_increment value, it will set it to the next available one.

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: