SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist MobileBadBoy's Avatar
    Join Date
    Jun 2002
    Location
    Mobile, Alabama
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Just a MySQL curiousity question

    This has always kind of made me wonder, but after testing something with my latest script, I figured it's about time I ask.

    What makes MySQL remember the last ID, and not recognize the last existing ID and auto increment from there instead? Just like, I have a script that tracks the click-throughs on any links out from my site, each link with it's own ID. Say if there are 34 links, and I add 2 more (35 & 36) and I delete those 2, then the next one added takes on the ID of 37. Why?

    Again, just a curiousity thing.
    Shawn Kerr .com

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhmm,
    I hope I can explain it.
    A column with AUTO_INCREMENT must be UNIQUE too.
    The scope of using AUTO_INCREMENT is to have a new unique id, an id that was never used.

    I think that MySQL store that number somewhere inside its data.

    It's like the numberplate of a car,
    even if I "demolish" the car I can't reuse that numberplate ( oh, in Italy is so ).

    I'm not a mysql expert,
    but I hope I have explained it well.



    pippo


    p.s.
    I remember a thread where MattR or M@rco explain it better than me, but I remember only...I have no trace of that thread.
    Last edited by pippo; Nov 2, 2002 at 00:39.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe if you look in your MySQL configuration there's a default MySQL database in there. I don't know if that's where it keeps track of these ID's, but it's something similar to that. It has to keep a list somewhere.
    $slider = 'n00b';

  4. #4
    SitePoint Wizard xyuri's Avatar
    Join Date
    Jul 2002
    Location
    Brisbane
    Posts
    1,487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Slider: Are you talking about the default database named "MySQL" with all the user information and stuff ?

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to a more appropriate forum

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


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
  •