Categories
Uncategorized

How to temporarily disable a foreign key constraint in MySQL?

Spread the love

To temporarily disable a foreign key constraint in MySQL, we set the FOREIGN_KEY_CHECKS environment variable.

To disable it, we run

SET FOREIGN_KEY_CHECKS=0;

to set FOREIGN_KEY_CHECKS to 0.

And then we enable it again by running

SET FOREIGN_KEY_CHECKS=1;

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *