SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Auto_increment

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto_increment

    What exactly does this do? I am hoping to make a database that stores e-mail addresses and allows them to be edited and new ones to be added. Would I need to use this in my table?

  2. #2
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The auto_increment is used to do pretty much what it's called. It increments the value in that field automatically. It's often used in ID fields, where the first row in a database is given the ID 1, then 2, 3, 4 and so forth.

    Here is more information in the MySQL documentation:
    http://dev.mysql.com/doc/refman/5.0/...increment.html
    Help build an entertaining technology hangout.
    Join us now, in the Computers and Technology chat room.

  3. #3
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See the article on my site for further clarification and how to use it with multiple tables as well.

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As far as I am concerned, I use Auto Increment to generate surrogate keys when appropriate natural keys are simply not available.

    Are there other usage as well?

  5. #5
    Worship the Krome kromey's Avatar
    Join Date
    Sep 2006
    Location
    Fairbanks, AK
    Posts
    1,621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kailash Badu
    Are there other usage as well?
    Friend of mine used it to keep a running tally of the number of rows in any given table. Until I pointed out what happens if a row is DELETEd...

    Other than that, all I've ever seen/heard of it used for is exactly what you (and I, for that matter) use it for - surrogate keys. Although I'm sure some sufficiently clever DBD could come up with some other use for it.

  6. #6
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Other than that, all I've ever seen/heard of it used for is exactly what you (and I, for that matter) use it for - surrogate keys. Although I'm sure some sufficiently clever DBD could come up with some other use for it
    I think so. Let rudy or longneck come in.


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
  •