简体   繁体   English

无法将Auto_increment值设置得较低,然后已在mysql中的InnoDB表上插入最大值

[英]Not able to set Auto_increment value lower then already inserted maximum value on InnoDB table in mysql

I have created 1 table. 我已经创建了1张桌子。 That table has Id field primary key and auto increment. 该表具有ID字段主键和自动递增。 Last inserted id is 15000. 最后插入的ID为15000。

Now I have manually inserted 99999 in this Id field.So I am getting next increment value as 100000. But I want my next auto_increment value 15001. 现在,我在此Id字段中手动插入了99999。因此,我得到的下一个增量值为100000。但是,我要下一个auto_increment值15001。

So for that i used alter table tbl_name auto_increment = 15001; 因此,为此,我使用了alter table tbl_name auto_increment = 15001;

But getting next auto_increment value as 100000. 但是获得下一个auto_increment值为100000。

I want next auto_increment value as 15001. 我希望下一个auto_increment值为15001。

How to do this on INNODB engine in mysql? 如何在mysql中的INNODB引擎上执行此操作?

The MySQL documentation is clear on that: MySQL文档在以下方面很明确:

You cannot reset the counter to a value less than or equal to the value that is currently in use. 您不能将计数器重置为小于或等于当前使用的值。 For both InnoDB and 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 AUTO_INCREMENT column value plus one. 对于InnoDB和MyISAM,如果该值小于或等于AUTO_INCREMENT列中当前的最大值,则该值将重置为当前的最大AUTO_INCREMENT列值加1。

What you are attempting can't be done with alter table . 使用alter table无法完成您尝试的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM