gpt4 book ai didi

mysql - 更改 MySQL 中自动增量值的当前计数?

转载 作者:IT老高 更新时间:2023-10-28 12:59:14 24 4
gpt4 key购买 nike

目前,每次我向数据库添加条目时,自动增量值都会增加 1,这是应该的。但是,它只是计数 47。所以,如果我添加一个新条目,它将是 48,然后另一个它将是 49,依此类推。

我想更改当前自动增量计数器的位置。 IE。我想将它从 47 更改为 10000,这样输入的下一个值将是 10001。我该怎么做?

最佳答案

您可以使用 ALTER TABLE设置 AUTO_INCREMENT 列的值;引用该页面:

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.

希望这会有所帮助!

关于mysql - 更改 MySQL 中自动增量值的当前计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1476512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com