gpt4 book ai didi

mysql - 更改 AUTO_INCREMENT 值

转载 作者:行者123 更新时间:2023-11-29 06:36:57 27 4
gpt4 key购买 nike

我正在使用 MySQL 5.6.12。我试过这个命令,但没有用。

ALTER TABLE food AUTO_INCREMENT = 1;  
ALTER TABLE food AUTO_INCREMENT=1;

我尝试使用我的 winform 应用程序和 EMS MySQL 管理器,都没有用。
我已经尝试了一些我在这里找到的答案,但还没有……

完全没有错误。查询执行完美,只是没有更改 AUTO_INCREMENT 值。

最佳答案

如果您试图降低自动增量值,它可能不会像您预期的那样工作。来自 MySQL Documentation :

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.

由于您试图将其设置为 1,除非表为空,否则这将不起作用,因为它必然小于当前最大值。

关于mysql - 更改 AUTO_INCREMENT 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23964968/

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