How to see foreign keys related to a table in MySql?
Background : I wanted to drop a table in MySql which has a foreign key constraint. When I do it I get this:
Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails
How can I drop foreign keys related to the table leaving others.
Best Answer
Firstly, find out your
FOREIGN KEY
constraint name in this way:You can also add (to the
WHERE
clause) if you have more than one table calledMy_Table
in different schemas.And then you can remove the named constraint in the following way:
References: 1 & 2.