重置主键auto_increment [英] Reset primary key auto_increment

查看:107
本文介绍了重置主键auto_increment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
重置mysql中的主键?

Possible Duplicate:
Reset primary key in mysql?

我什么时候有解决办法

delete from t1;

然后插入实体会强制id再次从id = 1开始吗?

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

insert into t1 values(...);

推荐答案

[...]然后插入实体会强制id再次从id = 1开始吗?

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

您可以这样ALTER TABLE:

ALTER TABLE t1 AUTO_INCREMENT = 1;

此处的文档: MySQL ALTER TABLE语法

这篇关于重置主键auto_increment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆