SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Primary Key

  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Primary Key

    I've created a column "userid". This column is primary key, auto_increment of type int [INT PRIMARY KEY AUTO_INCREMENT]. When I took a look at the table with Telnet, I saw that the type of the column "userid" is INT(11). But I was wondering, what happens when this column reaches id 99999999999?

  2. #2
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Newcastle, England
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When it reaches 99999999999, every single person on the planet has created about 20 accounts on your site.

    In other words, I wouldn't worry about it too much :P.

  3. #3
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When it reaches 99999999999, every single person on the planet has created about 20 accounts on your site.
    LOL

    I guess its a little silly to think about that now.

    But I'm just curious as to how MySQL works.

  4. #4
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use unsigned int

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, using UNSIGNED doubles the number of entries your table will be able to contain. When your table reaches the upper limit, MySQL will attempt to insert a new row with that same upper integer value, and you'll receive an error message complaining that you are attempting to insert a duplicate primary key value.

    Create a table with a TINYINT primary key column if you want to try it out.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


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
  •