Alex Rivera | Logout

Can't drop table: A foreign key constraint fails

Asked 2012-06-19T12:26:42.657
104

In MySQL I want to drop a table.
I tried a lot things but I keep getting the error that the table named bericht can't be dropped. This is the error I'm getting:

#1217 - Cannot delete or update a parent row: a foreign key constraint fails

How do I drop this table?

Edit
Report

1 Answer

96

Try this:

SELECT * 
FROM information_schema.KEY_COLUMN_USAGE 
WHERE REFERENCED_TABLE_NAME = 'YourTable';

This should deliver you which Tables have references to the table you want to drop, once you drop these references, or the datasets which reference datasets in this table you will be able to drop the table

answered 2012-06-19T12:31:32.950

Your Answer