4095
MariaDBERRORCommonHIGH confidence
InnoDB DB_ROW_ID column conflicts with foreign key
Production Risk
High — The DDL operation fails and the FK cannot be created.
Why it happens
- 1A table without an explicit primary key is referenced in a foreign key and the implicit row ID conflicts.
- 2Schema migration introduced a FK referencing a table that relies on the internal row ID.
Fix
Add an explicit primary key to the referenced table
Add an explicit primary key to the referenced table
ALTER TABLE t ADD COLUMN id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY;
Why this works
An explicit PK avoids InnoDB using DB_ROW_ID and resolves FK conflicts.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 4095 ER_INNODB_ROWID_COLUMN_EXISTS_IN_FK
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev