3123
MySQLERRORNotableDDLHIGH confidence
ALTER TABLE not supported: foreign key rename requires table copy
Production Risk
Medium — table copy locks can affect availability during the operation.
What this means
A column involved in a foreign key constraint is being renamed, which requires a full table copy and cannot be done in-place.
Why it happens
- 1Renaming a column that is part of a FOREIGN KEY constraint while using ALGORITHM=INPLACE.
How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE child RENAME COLUMN fk_col TO new_fk_col, ALGORITHM=INPLACE;
expected output
ERROR 3123 (HY000): ALGORITHM=INPLACE is not supported. Reason: Renaming a column used in a foreign key requires table copy.
Fix
Use ALGORITHM=COPY
Use ALGORITHM=COPY
ALTER TABLE child RENAME COLUMN fk_col TO new_fk_col, ALGORITHM=COPY;
Why this works
Table copy allows the foreign key metadata to be updated.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3123 ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FK_RENAME2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev