Saturday, May 9, 2015

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

You can encounter the following error in MariaDB (or MySQL):

MariaDB [db_test]> drop table application;
ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
MariaDB [db_test]>

If you want to disable foreign key checking, just do as follows:

MariaDB [db_test]> set foreign_key_checks=0;
Query OK, 0 rows affected (0.00 sec)

MariaDB [db_test]> drop table application;
Query OK, 0 rows affected (0.00 sec)

MariaDB [db_test]> set foreign_key_checks=1;
Query OK, 0 rows affected (0.00 sec)

MariaDB [db_test]>

Refernce:
http://stackoverflow.com/questions/3334619/cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails

No comments:

Post a Comment