Re: Dealing with auto-increment in MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 03 September 2007, Steve Finkelstein wrote:
> How're you folks dealing with records that are auto incremented in MySQL
> after a delete is made? I've noticed the only way to get a sequential order
> back is to truncate the table completely.
>
> Do you use logic in your code to find a missing ID and insert new records
> based on that? Or do you just ignore it, let mysql handle the numbering and
> go on with your lives?
>
> Just curious.
>
> Thanks!
>
> - sf

The whole point of a surrogate key is that it never changes, ever, and doesn't 
have any intrinsic meaning in and of itself.  If you want a unique ID that 
has meaning, don't use auto-increment.  It's an either/or question.  
Auto-increment and don't worry about what the numbers are as long as they're 
unique or do your own IDs that have some semantic meaning.  

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux