List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 7 2002 11:29pm
Subject:RE: Reset auto_increment
View as plain text  
At 14:57 -0600 2/7/02, Rick Emery wrote:
>The following deletes all records and re-starts renumbering from 1;
>DELETE FROM mytable;
>
>The following deletes all records and continues counting from where the
>table last left off:
>DELETE FROM mytable WHERE 1;
>
>If you are trying to restart numbering while not deleting records,
>forget-about-it.

ALTER TABLE tbl_name
DROP id,
ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
AUTO_INCREMENT = 1;

But why do this?  MySQL doesn't care if the sequence has holes in
it or not.

>-----Original Message-----
>From: Wei Gao [mailto:alexgaowei@stripped]
>Sent: Thursday, February 07, 2002 2:10 PM
>To: mysql@stripped
>Subject: Reset auto_increment
>
>
>Hi,
>As I am new to MySQL, perhaps this is a common question you have been asked.
>
>I have a field "Id" which using auto_increment. Now I want to reset the
>value of auto_increment, that is the "Id" starts form 1 and does not skip
>the number. I have spent a few hours to find a way, but all failed. Could
>you please tell me how to do it?
>
>Wei

Thread
Reset auto_incrementWei Gao7 Feb
RE: Reset auto_incrementRick Emery7 Feb
RE: Reset auto_incrementPaul DuBois8 Feb