Disable foreign key checks in MySQL

Disabling foreign key checks in MySQL is usefull when you are dealing with tables that use foreign keys (InnoDB engine).

You can not delete (drop) multiple tables, a parent table or a child table until you disable foreign key checks four your current database.

The sql command to disable foreign key checks is:

[sql]SET FOREIGN_KEY_CHECKS = 0;[/sql]

To enable the foreign key checks use the opposite command:

[sql]SET FOREIGN_KEY_CHECKS = 1;[/sql]

Permanent link to this article: https://blog.openshell.in/2012/09/disable-foreign-key-checks-in-mysql/

Leave a Reply

Your email address will not be published.