Log in

View Full Version : Resolved Primary key value after deleting a row



xtiano77
03-25-2009, 02:06 AM
I am new to MySQL, so forgive me if this question sounds too simple for those with more experience than me. Here it goes...

I have a table named "familypictures" which holds 30 rows. Now, after deleting a row and adding another one later, I noticed that the primary key, which is set to "auto_increment", doesn't take the next number after the last row. What I mean is that if I had 30 rows and deleted one, bringing me back to 29, and then add another row, the new row's primary key value will now have a value of 31. Shouldn't that row be renumbered back to 30?

Nile
03-25-2009, 02:26 AM
No... It doesn't work like that. Is there a reason you need it like that?

xtiano77
03-25-2009, 03:42 AM
Not really, I just wanted to confirm while at the same time make sure it was not going to affect any scripts in the future. Thanks for your reply.

Nile
03-25-2009, 11:57 AM
Ok, glad to help you!

It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"