List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 17 2001 8:36pm
Subject:RE: reset auto_increment?
View as plain text  
At 3:15 PM -0400 9/17/01, Jay Fesco wrote:
>  >  Can someone tell me how to reset a column's auto_increment starting point
>>   back to 0 in mysql ?
>>
>>   Thanks
>>
>>   Paul
>>
>According to Paul DuBois on page 169 of MySQL by New Riders (which you
>should buy):
>
>ALTER TABLE t
>     DROP i,
>     ADD i INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY
>
>Jay

Actually, this will drop the column and renumber the rows sequentially.

To just reset the sequence to 0 (well, to 1, since sequences start at 1),
do this:

ALTER TABLE t AUTO_INCREMENT = 1



-- 
Paul DuBois, paul@stripped
Thread
reset auto_increment?Paul Reilly17 Sep
  • RE: reset auto_increment?Jay Fesco17 Sep
    • RE: reset auto_increment?Paul DuBois17 Sep