Jump to content
Karaethon

Resetting Autoincrement

Recommended Posts

I need to reset my autoincrement value, I had a minor goof in my insert code and it ws inserting data wrong, i have fixed it but im now over 1000 rows in and all error posts are deleted, its not a big deal on a bigint but i want to start over at the beginning for my own OCD issues. how/can this be done?

Share this post


Link to post
Share on other sites
Posted (edited)

Truncate the table. It will also delete all the data.

	
TRUNCATE TABLE table_name;
TRUNCATE TABLE table_name;
Edited by benanamen
  • Like 1

Share this post


Link to post
Share on other sites

Another way is to simply:

 

ALTER TABLE table_name SET AUTO_INCREMENT=0;

 

Hope that helps.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.