Bogus foreign key constraint fail

前端 未结 9 1327
南笙
南笙 2020-11-28 01:52

I get this error message:

ERROR 1217 (23000) at line 40: Cannot delete or update a parent row: a foreign key constraint fails

<
9条回答
  •  伪装坚强ぢ
    2020-11-28 02:23

    On demand, now as an answer...

    When using MySQL Query Browser or phpMyAdmin, it appears that a new connection is opened for each query (bugs.mysql.com/bug.php?id=8280), making it neccessary to write all the drop statements in one query, eg.

    SET FOREIGN_KEY_CHECKS=0; 
    DROP TABLE my_first_table_to_drop; 
    DROP TABLE my_second_table_to_drop; 
    SET FOREIGN_KEY_CHECKS=1; 
    

    Where the SET FOREIGN_KEY_CHECKS=1 serves as an extra security measure...

提交回复
热议问题