Reset primary key auto_increment

Possible duplicate:
Reset primary key in mysql?

Is there any solution when I

delete from t1; 

and then insert objects so the identifier starts again with id = 1?

 insert into t1 values(...); 
+7
source share
2 answers

[...] then insert objects so the identifier starts again with id = 1?

You can ALTER TABLE as follows:

 ALTER TABLE t1 AUTO_INCREMENT = 1; 

Documentation here: MySQL ALTER TABLE Syntax

+10
source

Try trimming the table http://dev.mysql.com/doc/refman/5.1/en/truncate-table.html

Resets auto_increment columns back to 0.

+3
source

All Articles