Home >Database >Mysql Tutorial >How to disable MySQL foreign key checking and what are the benefits of disabling it?

How to disable MySQL foreign key checking and what are the benefits of disabling it?

PHPz
PHPzforward
2023-09-07 15:41:131116browse

How to disable MySQL foreign key checking and what are the benefits of disabling it?

We can disable foreign key checking with the help of the following statement-

mysql> Set foreign_key_checks = 0;
Query OK, 0 rows affected (0.00 sec)

We can enable it with the help of the following statement-

mysql> Set foreign_key_checks = 1;
Query OK, 0 rows affected (0.00 sec)

Disable foreign key Some benefits of key checking are as follows -

  • After disabling foreign key checking, we can load data into parent and child tables in any order. Otherwise, we have to load data in the parent table first and then in the child table.
  • We cannot drop tables referenced by foreign key constraints without disabling foreign key checking.
  • >

The above is the detailed content of How to disable MySQL foreign key checking and what are the benefits of disabling it?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete