Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member spasm attack's Avatar
    Join Date
    Aug 2006
    Location
    Colorado
    Posts
    15
    Member #
    13735
    What happens to a column that has auto increment when you delete a row? Do the other rows keep their original value or do they adjust so it is always one more than the previous entry? Example:
    Original
    ID - Name
    1 - Mark
    2 - Kevin
    3 - Ashley
    4 - Sarah

    And then lets say I delete the 2nd row. Does it become

    1 - Mark
    3 - Ashley
    4 - Sarah

    Or

    1 - Mark
    2 - Ashley
    3 - Sarah

    If it's the 2nd one I've got some work to do :Ogre:.
    "There is no spoone" -The Matricks

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    The first. The next time you insert a row that ro will be assigned the nextnumber sequentially.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    It's possible to adjust the behavior, but really there's no need to. Such a column is usually a surrogate key (vocabulary FTW: http://en.wikipedia.org/wiki/Surrogate_key ; it's a primary key whose sole purpose is to uniquely identify a row; it doesn't describe the row's data at all).

    You should never hardcode or assume IDs, anyway. You also shouldn't assume that one ID that is greater than another means the rows was created after the other.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:37 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com