5
According to what I read somewhere, the FOREIGN_KEY_CHECKS
:
... specifies whether or not to check foreign key restrictions for Innodb tables.
I mean, if the guy wants to disable the foreign key check, he does:
SET FOREIGN_KEY_CHECKS = 0;
I know it’s common to use this command in case of dumps to migrate bank, backups and things like... But I wonder if something that can disable the checking of foreign keys may or may not be harmful to an application.
I have the following questions:
- In what types of scenarios would be valid or not use
FOREIGN_KEY_CHECKS
with the value0
? FOREIGN_KEY_CHECKS
is something to be considered in restricting in production environment? It is something that can cause some kind of inconsistency in my application/database?- If it is possible to disable the change in
FOREIGN_KEY_CHECKS
, how is the procedure?
An analogy. The door of your house has a lock , leave the door open on the day of the change behind some risk !? It wouldn’t be safer to lock up and wait for the truck crew to ring the bell every time they bring it !?
– Motta
Personally, the scenario that I see to use this is that of the server that is not yet in production, that is, a supposed server that will be "the new", technically it is not necessary to use in the source server (as far as I understand), because it is usually possible to do the whole backup doing "reading" (and depending on the method you use for the dump). The "failure" of security, or better integrity failure is only really possible if you expose the new server, but it doesn’t have much sense to leave something that is not yet "ready" active for other people right? :)
– Guilherme Nascimento