Sunday, April 8, 2012

MySQL disable key

Some times you just need do to some quick editing but you have some foreign keys which prevent that. MySQL just tells:

Cannot delete or update a parent row: a foreign key constraint fails

The most easy way is to temporally disable the foreign keys whit:
SET FOREIGN_KEY_CHECKS=0;

DELETE or what ever

SET FOREIGN_KEY_CHECKS=1;