3406
MariaDBERRORNotableForeign KeysHIGH confidence

Foreign key column not found in table

Production Risk

Low — DDL fails; no constraint is created.

How to reproduce
trigger — this will error
trigger — this will error
ALTER TABLE child ADD FOREIGN KEY (nonexistent_col) REFERENCES parent(id);

expected output

ERROR 3406 (HY000): Foreign key column does not exist in the table.

Fix

Verify column name with DESCRIBE

Verify column name with DESCRIBE
DESCRIBE child; ALTER TABLE child ADD FOREIGN KEY (actual_col_name) REFERENCES parent(id);

Why this works

DESCRIBE shows exact column names to use in the foreign key constraint.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3406 ER_FK_COLUMN_NOT_FOUND_IN_TABLE

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors