SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2013
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Resetting id after deleting entries in MySQL

    I'm on Chapter 7 of PHP and MySQL: Novice to Ninja and have successfully set up an admin page that allows me to delete entries in my database tables. I've noticed that when I delete an entry and then an add a new one that the id for the old entry is skipped and the numbering resumes after the skip or skips. For example:

    1
    2
    4
    5

    Where 3 was the id of a deleted entry. Is this something that will be covered later in the book or is it even an issue to be concerned about?

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,070
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    I've never read the book, so I'm not sure if it will be covered, but this is normal behavior for auto_increment tables. The database will keep working just fine. Also, the is no way (at least, no simple way) to fill up those gaps. I wouldn't worry about it.

    And no need to worry that you'll need those numbers because your table will get "full", because it goes up to 2,147,483,647 (that's for a signed int, for unsigned it even goes up to 4,294,967,295). If you're convinced that's not enough you can always go for unsigned bigint, which goes up to 18,446,744,073,709,551,615. But unless you're building the next twitter or facebook, you'll probably not going to be needing that
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2013
    Posts
    35
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    I've never read the book, so I'm not sure if it will be covered, but this is normal behavior for auto_increment tables. The database will keep working just fine. Also, the is no way (at least, no simple way) to fill up those gaps. I wouldn't worry about it.
    Thank you!


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
  •