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 −
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.
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.