Hi,
is there an SQL command for making a primary key (auto number key) to start numbering
from beginning after deleting all the records from the table.
thanks
delete all records by this command:
TRUNCATE TABLE `mytable`;
- Original Message -
From: Miroslav I. [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 8:10 AM
Subject: auto number primary key - restarting
Hi,
is there an SQL command for making a primary key (auto
Miroslav I. [EMAIL PROTECTED] wrote:
is there an SQL command for making a primary key (auto number key) to start
numbering from beginning after deleting all the records from the table.
For MyISAM tables you can use ALTER TABLE:
http://www.mysql.com/doc/en/ALTER_TABLE.html
--
For
Please check the history on this list. There are numerous answers to
this problem.
Cheers
/rudy
-Original Message-
From: Miroslav I. [mailto:[EMAIL PROTECTED]
Sent: dinsdag 15 juli 2003 14:10
To: [EMAIL PROTECTED]
Subject: auto number primary key - restarting
Hi,
is there an SQL
Hello Miroslav,
Tuesday, July 15, 2003, 3:10:10 PM, you wrote:
Easiest way to do what you want is to make this:
1.SHOW CREATE TABLE TableName
and copy SQL
2. DROP TABLE TableName
3. CREATE TABLE - with SQL copied in 1.
MI Hi,
MI is there an SQL command for making a primary key (auto number
Easiest way to do what you want is to make this:
1.SHOW CREATE TABLE TableName
and copy SQL
2. DROP TABLE TableName
3. CREATE TABLE - with SQL copied in 1.
Actually, the easiest way to do this (assuming *all*
records have been deleted) is:
UPDATE table_name SET auto_increment_field = 0;
To: Krasimir_Slaveykov; Miroslav I.; [EMAIL PROTECTED]
Subject: Re: auto number primary key - restarting
Easiest way to do what you want is to make this:
1.SHOW CREATE TABLE TableName
and copy SQL
2. DROP TABLE TableName
3. CREATE TABLE - with SQL copied in 1.
Actually, the easiest way to do this (assuming
truncate table_name
does both in one statement. And even optimizes the table (frees up
unused disk space). However take care that you cannot rollback this DDL.
Wow. Learn something new every day! :p
Thanks for the tip, Rudy!
Chris
--
MySQL General Mailing List
For list archives: