[英]PROBLEM WITH - AUTO_INCREMENT VALUE IN TABLE_SCHEMA NOT UPDATING
SCENARIO设想
ALTER TABLE {TABLE NAME} AUTO_INCREMENT = 1; ALTER TABLE {TABLE NAME} AUTO_INCREMENT = 1;
INSERT INTO {TABLE NAME} ({COLUMN}) VALUES (1);插入 {TABLE NAME} ({COLUMN}) 值 (1); (this is only record in table after auto increment was updated) (这只是自动增量更新后的表中的记录)
SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = {DATABASE NAME} AND TABLE_NAME = {TABLE NAME}; SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = {DATABASE NAME} AND TABLE_NAME = {TABLE NAME};
the last select auto_increment is returning the old value before execution alter table in step 1) and I don't understand why and hot to fix it or maybe alter table in step 1) is not correct way to reset auto_increment.最后一个 select auto_increment 在步骤 1) 中执行 alter table 之前返回旧值,我不明白为什么和热修复它或者可能在步骤 1) 中更改表不是重置 auto_increment 的正确方法。
THX谢谢
PS. PS。 I know a bit but not everything.我知道一点,但不是全部。 I was researching this problem and didn't find satisfactory/explanatory answer.我正在研究这个问题,但没有找到满意/解释性的答案。
I guess you must set AUTO_INCREMENT = 1 not 0我猜你必须设置 AUTO_INCREMENT = 1 而不是 0
The INFORMATION_SCHEMA doesn't update to reflect recent alterations. INFORMATION_SCHEMA 不会更新以反映最近的更改。 MySQL 8.0 changed it so it only updates once every 24 hours. MySQL 8.0 对其进行了更改,因此它仅每 24 小时更新一次。
You can set this:你可以这样设置:
SET GLOBAL information_schema_stats_expiry=0;
That will make INFORMATION_SCHEMA update immediately, at the cost of some overhead on your system.这将使 INFORMATION_SCHEMA 立即更新,代价是系统开销。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.