开发者

Reset primary key auto_increment [duplicate]

开发者 https://www.devze.com 2023-03-11 15:14 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Reset primary key in mysql?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Reset primary key in mysql?

Is there any solution开发者_StackOverflow中文版 to when I

delete from t1;

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

insert into t1 values(...);


[...] 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


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

This resets auto_increment columns back to 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消