- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Does MySQL foreign_key_checks affect the entire database?
152 Lectures 16 hours
87 Lectures 5.5 hours
The foreign_key_checks are session based. Now, we can say that they are for scope i.e. local or global. Here is an example demo of local or global. Both are scopes and we can set this for session.
Let us set the scope −
mysql> set foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec) mysql> set global foreign_key_checks = 0; Query OK, 0 rows affected (0.05 sec)
The foreign_key_checks variables are server system variables. Here are some more details −
Setting foreign_key_checks to 0
It affects data definition statements: DROP SCHEMA drops a schema even if it contains tables that have foreign keys that are referred to by tables outside the schema, and DROP TABLE drops tables that have foreign keys that are referred to by other tables.
Setting foreign_key_checks to 1
It does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks=0 will not be verified for consistency.
- Verify that MySQL SET FOREIGN KEY CHECKS is set to = 1?
- How to disable MySQL foreign key checks and what are the benefits of disabling it?
- Difference between Primary key and Foreign key in Database
- Difference between Primary key and Foreign key in SQL Database
- MySQL Syntax to create Foreign Key?
- Foreign Key in RDBMS
- How to identify foreign key in MySQL DB?
- Get a list of Foreign Key constraints in MySQL
- How to use Primary Key Constraints and Foreign Key Constraints to enforce database integrity in Oracle?
- Difference Between Primary key and Foreign key in DBMS
- What does the KEY keyword mean in MySQL?
- sp_help for MySQL to display field types and foreign key constraints?
- Where does MySQL store database files?
- Foreign key referencing of two DB2 tables
- How does the “Pica” disorder affect kids?