SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Question on deleting Data from a mysql database

    I was deleting some several info from my database by there id number.
    I use this syntax “Delete From [table name] where id=[id number].

    It successfully delete the id number with it info but when I look at the database the ID number in the database is out of order. For example lets say I deleted Id number 10 when I look at the database in Mysql the id numbers show up as... 7 8 9 11 12...

    And when I add new data to the database the id number does not replace the old number but just continues on.

    Any one got an explanation?
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svíţjóđ
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I deleted Id number 10 when I look at the database in Mysql the id numbers show up as... 7 8 9 11 12...
    Yes, and that's the way it should work
    I hope you don't mean that the IDs 11 12 ... should be renamed 10 11 ...
    If you have a table with 2 million rows and delete the first row, do you want to wait for the 1999999 updates?
    But this not the biggest problem
    Imagine this: You send a question to this forum and the new thread gets the ID 66585, someone finds the thread interesting and include a link to it on another page
    If some thread with ID 1...66584 is deleted, your thread is still number 66585 and the link is still valid
    etc etc
    http://www.webopedia.com/TERM/R/refe...integrity.html

  3. #3
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you scared that you will run out of IDs?

    Check MySQL.com and see how big unsigned integers can be, it will relieve you.

    I think this question should go into FAQ or question guidelines at the top of this forum. It has been asked quite many times.
    IMHO

  4. #4
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps it should be on a FAQ, I bet I must not be the only one who have asked this question.
    I was not really worried about the idea of running out of id numbers.
    I was just not clear on the concept of the id numbers and the reason it follow that pattern to be deleted. Jofa example cleared everything up to me.

    Appreciate the help, and thanks for the responses.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?


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
  •