如何仅更改单个 table 的自动增量偏移量和步长值?

How to change autoincrement offset and step value for only a single table?

我有一个单体数据库,其中 table 有大约 6000 万行。 该设置是 master-master 复制的,其中一个 master 写入偶数自动增量 ID,而其他 master 写入奇数自动增量 id。

但我想更改设置,以便我可以对整个数据库中的单个 table(有问题的 table)使用步长 4 和偏移量 1 和 3。 有可能吗?

没有

MySQL 文档明确指出自动增量偏移量是每个 MySQL 实例设置,并将应用于数据库中的所有表。

可以在 https://dev.mysql.com/doc/refman/8.0/en/replication-options-master.html#sysvar_auto_increment_increment.

查看文档

It is not possible to restrict the effects of these two variables to a single table; these variables control the behavior of all AUTO_INCREMENT columns in all tables on the MySQL server. If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.