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
Release: 2023-09-07 15:41:13
forward
1072 people have browsed it

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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template