Auto Increment has been reset back to 1 automatically(自动增量已自动重置回 1)
问题描述
我刚刚遇到了一个我无法解决的问题.
I've just run into an issue which I'm not able to solve.
我有一个数据库表 project_queues
用作队列,我在其中存储一些记录.当记录被处理时,它们被删除.删除由 Rails 构造 record.destroy
在循环中调用,该循环触发 MySql 数据库上的 DELETE record FROM table
.
I have a database table project_queues
which is used as a queue, where I store some records. When the records are processed, they are deleted.
Deletion is invoked by rails construction record.destroy
in a loop which triggers DELETE record FROM table
on MySql database.
但现在我注意到,在 project_queues
表中,autoIncrement Id(主键)被设置回 1.(这损坏了我在审计表中的引用.相同的记录现在指向多个不同的项目队列)
But now I've noticed, that in the table project_queues
the autoIncrement Id (primary key) was set up back to 1. (Which damaged my references in the audit table. The Same record now points to multiple different project queues)
show create table project_queues;
CREATE TABLE `project_queues` (
`id` int(11) NOT NULL AUTO_INCREMENT,
...
...
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=1
我不使用 TRUNCATE project_queues
或删除表结构并在代码中重新创建它.
I do not use TRUNCATE project_queues
or drop the table construction and created it again in code.
有没有人和我一样遇到过类似的问题?我在日志中也找不到任何异常.
Did somebody run into a similar issue like me? I can't find any anomalies in the log either.
我正在使用 Rails 5.2.3、MariaDB 10.1.
从应用程序到数据库的连接强制执行这种 SQL 模式:
The connection from the application to database enforces this SQL modes:
- NO_AUTO_VALUE_ON_ZERO
- STRICT_ALL_TABLES
- NO_AUTO_CREATE_USER
- NO_ENGINE_SUBSTITUTION
- NO_ZERO_DATE
- NO_ZERO_IN_DATE
- ERROR_FOR_DIVISION_BY_ZERO
但我不认为这些与人工智能有关.
But I don't think that these have something to do with AI.
推荐答案
已解决
我已将 10.1.29-MariaDB MariaDB Server
升级到 10.2.8-MariaDB MariaDB Server
版本 >= 10.2.4 已解决自动增量值的重置
Version >= 10.2.4 has solved the resetting of Auto Increment value
这篇关于自动增量已自动重置回 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自动增量已自动重置回 1


- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01