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:

SET FOREIGN_KEY_CHECKS = 0;

To  enable the foreign key checks use the opposite command:

SET FOREIGN_KEY_CHECKS = 1;

About Cristian Radulescu

PHP // MySql // Linux // Android
This entry was posted in MySQL, Programming and tagged , , . Bookmark the permalink.

3 Responses to Disable foreign key checks in MySQL

  1. Flo says:

    Thanks!
    Safed me from a lot of trouble :)

    Flo

  2. Thanks a lot! Very helpful info.

  3. Ting Wang says:

    Thank a lot, very helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>