High severitydata integrity
Power BI Refresh Error:
1215
What does this error mean?
An ALTER TABLE or CREATE TABLE failed to add a FK constraint — usually due to a missing index or data type mismatch.
Common causes
- 1The referenced column in the parent table has no index (MySQL requires an index on the referenced column)
- 2Data type mismatch between child FK column and parent referenced column (e.g., INT vs BIGINT)
- 3Character set or collation mismatch between the two columns
- 4Existing data in the child column has values with no matching parent row
How to fix it
- 1Step 1: Check that the referenced parent column has an index: `SHOW INDEX FROM parent_table;` — add one if missing: `ALTER TABLE parent_table ADD INDEX (referenced_col);`
- 2Step 2: Verify data types match exactly: `DESCRIBE child_table;` and `DESCRIBE parent_table;` — both FK and referenced columns must have identical type, length, and sign.
- 3Step 3: Check for orphaned data: `SELECT child.fk_col FROM child LEFT JOIN parent ON child.fk_col=parent.id WHERE parent.id IS NULL;`
- 4Step 4: Temporarily use `SET FOREIGN_KEY_CHECKS=0;` to add the constraint definition, then fix data, then re-enable.
Frequently asked questions
Official documentation: https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html