Skip to content
Advertisement

How can I temporarily disable a foreign key constraint in MySQL?

Is it possible to temporarily disable constraints in MySQL?

I have two Django models, each with a foreign key to the other one. Deleting instances of a model returns an error because of the foreign key constraint:

Is it possible to temporarily disable constraints and delete anyway?

Advertisement

Answer

Try DISABLE KEYS or

Make sure to

after.

Advertisement