1

我有一个超过 6000 条记录的 mysql innoDB 表。主键 (ID) 设置为 auto_incremented。此时 auto_increment 值为 41804。

我通过insert语句插入了2000多条记录,发现一些查询有一些数据问题。此时 auto_increment 值已更改为 42500。

我修复了插入语句中的数据问题,从表中删除了新插入的记录,并将 auto_increment 值更改为 41804(增加 10)

alter table mytable auto_increment = 41804

我再次运行插入语句 - 这次我收到错误代码:1062 - 键 'PRIMARY' 的重复条目 '320-41804'

最大 ID 值为 41794,auto_increment 值为 41804 - 没有 ID 值为 41804 的记录 - 但我仍然收到重复键错误。

任何人都可以对此有所了解吗?

非常感激。

4

0 回答 0