How to make an id auto_increment from where it last left off after a record delete?
Posted
by Sammy
on Stack Overflow
See other posts from Stack Overflow
or by Sammy
Published on 2010-03-27T21:44:15Z
Indexed on
2010/03/27
21:53 UTC
Read the original article
Hit count: 268
mysql
This isn't that big of a deal but I was wondering if it can be done. Right now when I insert a new record, the id field which is auto_increment and set as primary key increases it's value by one:
id | first_name | last_name
------------------------------
1 | John | Smith
2 | Jane | Doe
But if I delete record 2, the next one I insert is going to have an id of 3. Is there any way to make it have an id of 2 automatically (without having to manually insert it)?
© Stack Overflow or respective owner