4109
MariaDBERRORNotableHIGH confidence
Incorrect foreign key definition
Production Risk
Low — DDL fails; no data is modified.
Why it happens
- 1The FK references columns with incompatible data types.
- 2The FK definition is syntactically malformed.
- 3The referenced table or column does not exist.
Fix 1
Verify FK column data types match
Why this works
Both the FK column and the referenced column must have identical data types and lengths.
Fix 2
Ensure the referenced table and column exist
Ensure the referenced table and column exist
SHOW CREATE TABLE referenced_table;
Why this works
Confirms the referenced table structure before adding the FK.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 4109 ER_WRONG_FK_DEF2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev