delete all records and reset autonumber fields

[expired user #5814]'s profile image [expired user #5814] posted 13 years ago in General Permalink
How can I delete all records in my database and reset the AutoNumber field in a single command?
ansgar's profile image ansgar posted 13 years ago Permalink
Well you need two commands, not one:
TRUNCATE mytable;
ALTER TABLE mytable AUTO_INCREMENT=0;
[expired user #5821]'s profile image [expired user #5821] posted 13 years ago Permalink
As far as i know TURNCATE TABLE resets the AUTO_INCREMENT value.

Cheers
Robert
[expired user #5821]'s profile image [expired user #5821] posted 13 years ago Permalink
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.