You must have faced the foreign key constrains issues many times while working with MySQL database. Generally this issue occurred during delete, insert records, backup and restore database and drop database and drop tables. In this situation its hard to complete task. MySQL provides an option to disable foreign key checks during any operation on tables or databases. You can disable check and complete your task without any issues.

Advertisement

This article will help you to how to enable or disable foreign key check in MySQL. Ever you faced foreign key error, Disable foreign key checks, do you work and enable it again.

Disable Foreign Key Checks

SET FOREIGN_KEY_CHECKS=0;

Enable Foreign Key Checks

SET FOREIGN_KEY_CHECKS=1;

Remember that, do not forgot to re-enable foreign key checks again after doing your work.

Share.
Leave A Reply

Exit mobile version