1784
MariaDBERRORNotableDDLHIGH confidence
INPLACE ALTER not supported with foreign key check
Production Risk
Low — DDL rejected.
What this means
The in-place ALTER TABLE operation cannot be performed because foreign key constraint validation is required and is incompatible with INPLACE.
Why it happens
- 1Adding a foreign key or changing the referenced column requires full FK validation, which needs COPY.
How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE child ALGORITHM=INPLACE, ADD CONSTRAINT fk1 FOREIGN KEY (pid) REFERENCES parent(id);
expected output
ERROR 1784 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type: FOREIGN KEY CHECK.
Fix
Add the foreign key using ALGORITHM=COPY
Add the foreign key using ALGORITHM=COPY
ALTER TABLE child ALGORITHM=COPY, ADD CONSTRAINT fk1 FOREIGN KEY (pid) REFERENCES parent(id);
Why this works
COPY performs the full FK validation during the table rebuild.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1784 ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_CHECK
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev