Saturday, January 28, 2012

MYSQL issue : Cannot delete or update a parent row: a foreign key constraint fails

mysql> drop table mgDoctorProfile;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
mysql>

Reason : You might have some constraints defined for this table in the child table. Even if you delete the child table, the contraints exists. To resolve the issue execute the following:

mysql> SET FOREIGN_KEY_CHECKS=0;

Then Delete the Parent Table and run the following command again:


mysql> SET FOREIGN_KEY_CHECKS=1;

No comments:

Post a Comment