加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

当大量数字已存在时重置MySQL auto_increment?

发布时间:2021-04-01 19:12:01 所属栏目:MySql教程 来源:网络整理
导读:我有一个带有自动递增列的表.我需要将其中一行设置为1000而不再触摸它,但现在我已将其设置为1000,自动增量保持从1001开始并拒绝从1开始.有没有办法解决这个问题?最佳答案你不能: To change the value of the AUTO_INCREMENT counter to be used for new

我有一个带有自动递增列的表.我需要将其中一行设置为1000而不再触摸它,但现在我已将其设置为1000,自动增量保持从1001开始并拒绝从1开始.有没有办法解决这个问题? 最佳答案 你不能:

To change the value of the
AUTO_INCREMENT counter to be used for
new rows,do this:

ALTER TABLE t2 AUTO_INCREMENT = value;

You cannot reset the counter to a
value less than or equal to any that
have already been used. For MyISAM,if
the value is less than or equal to the
maximum value currently in the
AUTO_INCREMENT column,the value is
reset to the current maximum plus one.
For InnoDB,if the value is less than
the current maximum value in the
column,no error occurs and the
current sequence value is not changed.

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

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读