【问题标题】:MySQL skipping 2147483646 on int(11) auto increment columnMySQL 在 int(11) 自动增量列上跳过 2147483646
【发布时间】:2018-12-05 18:08:30
【问题描述】:

这是我的代码:

create table test3 (
    num int(11) not null auto_increment,
    primary key (num)
) auto_increment=2147483644;

insert into test3 values();
insert into test3 values();
insert into test3 values();
insert into test3 values(); //duplicate key error

select * from test3;

您会注意到使用了 2147483644、2147483645 和 2147483647,但没有使用 2147483646。我可以手动将某些内容设置为 2147483646,但我想了解为什么会发生这种情况。我的 innodb autoinc 锁定模式是 1(我的版本的默认值)。

【问题讨论】:

标签: mysql innodb auto-increment


【解决方案1】:

这种行为在 2015 年之前曾被报告为错误:

Bug #75941 auto_increment value jumps from the max row value - 2 to max

该错误报告中的一条评论声称该错误已在几年前(大约 2010-2011 年)被报告。

还没有修复。我刚刚测试了 MySQL 8.0.11,行为还是和你描述的一样。

如果您想提高错误的优先级,您应该登录 MySQL 错误站点并单击“影响我”按钮。

无论如何,您不应依赖自动递增键的值是连续的。他们唯一的要求是独一无二。

【讨论】:

    猜你喜欢
    • 2015-07-05
    • 2012-02-22
    • 2016-10-01
    • 1970-01-01
    • 2011-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    相关资源
    最近更新 更多