PDA

View Full Version : stop auto_increment from jumping


wiffles
08-24-2004, 05:19 PM
One of my MySQL tables has an ID column - it's a primary key with auto_increment. And it works. If I add six rows they number 1 to 6 nicely. But if I delete rows 4 to 6 then add a new row, it becomes row 7. And if I delete that it becomes row 8. How can I make it so the next auto_increment is the smallest possible? (i.e. 1,2,3,4,5,6 - I delete 4-6 and the next row inserted becomes 4)

scoutt
08-24-2004, 05:54 PM
you can't. you can however backup the data and delete th table an then redo it with the ids in order. but then you will be in the same spot as you are now if you deleted a row.

wiffles
08-25-2004, 07:32 AM
Ok... I'll do the IDs manually then.
Thanks