Results 1 to 4 of 4

Thread: Primary key value after deleting a row

  1. #1
    Join Date
    Sep 2008
    Location
    Midland, Texas
    Posts
    52
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Question Primary key value after deleting a row

    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?
    Last edited by xtiano77; 03-25-2009 at 03:42 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No... It doesn't work like that. Is there a reason you need it like that?
    Jeremy | jfein.net

  3. #3
    Join Date
    Sep 2008
    Location
    Midland, Texas
    Posts
    52
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    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"
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •