Jump to content

[SOLVED] Resetting auto-increment in database


cliftonbazaar

Recommended Posts

I found this reply for a similar problem on MySQL,

 

In order to reset the auto_increment, in a situation where some of the most recently added rows were deleted, use:

 

ALTER TABLE theTableInQuestion AUTO_INCREMENT=1234

 

and future insertions will be numbered from 1234 again (unless you still had rows numbered greater than 1234, and then the future insertions will start from the greatest number + 1 ).

 

 

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

 

 

Hope this helps.

 

Link to comment
Share on other sites

Wow - didn't know you could do that. Tis pretty useful.

 

Me either, just found it on Google.  As far as helpfulness, I've never actually needed to do something like this.  But I could see how such large numbers could get annoying.

Link to comment
Share on other sites

I agree. Oddly, my users table suddenly started incrementing from 60,000 one day, so I tried changing user's IDs back to their proper value but new users still incremented from 60,000. I think I shall try this :D

 

Yes, it's meant to do this to retain its "uniqueness".  But ALTERing the table this way, should work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.