Search code examples
mysqlinnodb

What is the scope of 'SET foreign_key_checks = 0'?


Can't really find any details on this, but is the scope of 'SET foreign_key_checks = 0' the current connection, current session or current transaction?


Solution

  • It's a session-based statement.

    This is to temporarily break the Foreign Key Constraint. It is sometimes necessary to change data in a way that referential integrity needs to be broken during the modification process.