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:[EMAIL PROTECTED]]
>Sent: Thursday, February 07, 2002 2:10 PM
>To: [EMAIL PROTECTED]
>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


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

  • ... Wei Gao
    • ... Rick Emery
      • ... Paul DuBois
    • ... Wei Gao
    • ... Rick Emery
    • ... INVALID - TESTING ONLY. IF YOU GET EMAIL WITH THIS ACCOUNT PLEASE REPLY TO [EMAIL PROTECTED] INSTEAD. OBVIOUSLY WE MADE A MISTAKE IF YOU ARE READING THIS
      • ... Paul DuBois
    • ... Mike Blezien
      • ... Trevor Rhodes

Reply via email to