distal-attribute
distal-attribute
distal-attribute
distal-attribute

delete all records and reset autonumber fields

User, date Message
Written by afal3d
3 years ago
Category: General
14 posts since Wed, 06 Jul 11
How can I delete all records in my database and reset the AutoNumber field in a single command?
Written by ansgar
3 years ago
4936 posts since Fri, 07 Apr 06
Well you need two commands, not one:

TRUNCATE mytable;
ALTER TABLE mytable AUTO_INCREMENT=0;

Written by csiqojerncjsa
3 years ago
12 posts since Sun, 10 Jul 11
As far as i know TURNCATE TABLE resets the AUTO_INCREMENT value.

Cheers
Robert
Written by csiqojerncjsa
3 years ago
12 posts since Sun, 10 Jul 11
From MySQL 5.0.13 on, the AUTO_INCREMENT counter is reset to zero by TRUNCATE TABLE, regardless of whether there is a foreign key constraint.
 

Please login to leave a reply, or register at first.