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

delete all records and reset autonumber fields

afal3d posted 3 years ago in General
How can I delete all records in my database and reset the AutoNumber field in a single command?
ansgar posted 3 years ago
Well you need two commands, not one:

TRUNCATE mytable;
ALTER TABLE mytable AUTO_INCREMENT=0;

csiqojerncjsa posted 3 years ago
As far as i know TURNCATE TABLE resets the AUTO_INCREMENT value.

Cheers
Robert
csiqojerncjsa posted 3 years ago
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.