List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 18 1999 2:38pm
Subject:Re: renumbering an auto-increment
View as plain text  
At 6:26 AM -0700 1999-12-18, Sasha Pachev wrote:
>toxalot@stripped wrote:
>>
>>  Is there an easy way to renumber an auto-increment?  The column now has
>>  many unused numbers and is getting quite high.  There are no other tables
>>  that use a join with this column so that is not a concern.
>>
>>  I would just like to tidy it up and renumber everything starting with 1.
>>
>>  Thanks
>>
>>  Jennifer
>>
>>
>
>The auto_increment field is really the one you should not even be
>looking at yourself :-), that's why it's auto, and, unlike humans,
>computers work just as fast on 32-bit integers from 0 to 1000 as they do
>on the ones from 1,000,000 to 3,000,000 :-)
>
>However, if this really bothers you, it can be done with a little bit of
>Perl (or maybe even without), although very not recommended if your
>auto_increment field is referenced in other tables.


If it's referenced by other tables, yes, don't even think about
renumbering it.  Otherwise, an easy way to rebuild the column
is to use ALTER TABLE to drop the column and and add it again.
MySQL will sequence it for you, beginning with 1.

-- 
Paul DuBois, paul@stripped
Thread
renumbering an auto-incrementtoxalot18 Dec
  • Re: renumbering an auto-incrementSasha Pachev18 Dec
    • Re: renumbering an auto-incrementPaul DuBois18 Dec
    • Re: renumbering an auto-incrementAaron18 Dec