Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



MySQL - How to rese...
 
Share:
Notifications
Clear all

[Solved] MySQL - How to reset Auto Increment fields

1 Posts
1 Users
0 Reactions
2,171 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2869
Topic starter  

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 ).

So you cold also use:

ALTER TABLE theTableInQuestion AUTO_INCREMENT=0

Which resets auto increment to the highest number used.


   
ReplyQuote
Share: