8

Possible Duplicate:
Reset primary key in mysql?

Is there any solution to when I

delete from t1;

and then insert entities force the id to begin from id=1 again?

insert into t1 values(...);
Community
  • 1
  • 1
Nickool
  • 3,662
  • 10
  • 42
  • 72

2 Answers2

13

[...] then insert entities force the id to begin from id=1 again?

You can ALTER TABLE like this:

ALTER TABLE t1 AUTO_INCREMENT = 1;

Documentation here: MySQL ALTER TABLE Syntax

aioobe
  • 413,195
  • 112
  • 811
  • 826
3

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

This resets auto_increment columns back to 0.

eroomydna
  • 1,261
  • 9
  • 4