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

0 votes
Hello, I get error ERROR 1217 (23000) at line : Cannot delete or update a parent row: a foreign key constraint fails

while try importing an sql

Is there any way to fix it easily?
asked Apr 30, 2015 by super (900 points)

1 Answer

0 votes
Best answer
You should add these lines to your sql SET FOREIGN_KEY_CHECKS=0; to the beginning and SET FOREIGN_KEY_CHECKS=1; to the end.

following this example:

SET FOREIGN_KEY_CHECKS=0;

your queries....

Drop tables....

SET FOREIGN_KEY_CHECKS=1;
answered Apr 30, 2015 by vinhvinh (570 points)
selected Apr 30, 2015 by super
Welcome to Expert Customize Forum, where you can ask any IT questions and get free support by Our experts
You have projects or tasks? Want to hire Quality expert? Try our Web expert service