ExpertRefresh

Administration / Foreign key disable  

1) How to temporary disable FK





2) Turn off FK contraint




3) Turn off FK contraint globally







Temporary disable foregin keys

ALTER TABLE article DISABLE KEYS; SET FOREIGN_KEY_CHECKS=0; ... do you processing ... SET FOREIGN_KEY_CHECKS=1; ALTER TABLE article ENABLE KEYS; There are two foreign_key_checks variables: a global variable and a local (per session) variable. Upon connection, the session variable is initialized to the value of the global variable. The command SET foreign_key_checks modifies the session variable.

Globally

To turn off foreign key constraint globally, do the following SET GLOBAL FOREIGN_KEY_CHECKS=0; ... SET GLOBAL FOREIGN_KEY_CHECKS=1;

Empty dependent table

You shouldn't be able to drop a table that is the parent of another dependent table, even if it has no data


References



n/a