Find references MySql table
Got a foreign key reference unable to delete a record from a table in MySql
This error in particular MYSQL ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
Error code 1217
This query will show the possible references that would cause this interdependency issue
SELECT
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_SCHEMA = 'your_db' AND
REFERENCED_TABLE_NAME = 'the_table_in_question';
TABLE_NAME | COLUMN_NAME |
---|---|
PlaceLock | TableId |
AlternateBlackoutTable | TableId |