Error number: 3941; Symbol: ER_ALTER_CONSTRAINT_ENFORCEMENT_NOT_SUPPORTED; SQLSTATE: HY000
Message: Altering constraint enforcement is not supported for the constraint ‘%s’. Enforcement state alter is not supported for the PRIMARY, UNIQUE and FOREIGN KEY type constraints.
ER_ALTER_CONSTRAINT_ENFORCEMENT_NOT_SUPPORTED 错误号:3941,SQLSTATE:HY000
错误说明:
ER_ALTER_CONSTRAINT_ENFORCEMENT_NOT_SUPPORTED 错误号:3941,SQLSTATE:HY000 错误消息是MySQL的一种常见的错误,该错误发生时,表示ALTER TABLE语句试图边调整一个约束的启用/禁用,但MySQL不支持这样的约束调整。
例如,下面的语句试图强制禁用一个叫做my_idx的索引:
ALTER TABLE t1 ALGORITHM=INPLACE,LOCK=NONE DISABLE KEYS my_idx;
然而,上述语句会导致以下错误:
ERROR 3941 (HY000): Alter table with ALGORITHM=INPLACE,LOCK=NONE is not supported for altering constraint enforcement. Try ALGORITHM=COPY.
解决方法:
要解决这个错误,可以使用COPY算法,而不是INPLACE算法。因此,要解决上面的错误,只需更改语句,将ALGORITHM=INPLACE替换为ALGORITHM=COPY,然后再次尝试。
ALTER TABLE t1 ALGORITHM=COPY,LOCK=NONE DISABLE KEYS my_idx;