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.
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.
Advertisement
Disable Foreign Key Checks
SETFOREIGN_KEY_CHECKS =0 ;
Enable Foreign Key Checks
SETFOREIGN_KEY_CHECKS =1 ;
Remember that, do not forgot to re-enable foreign key checks again after doing your work.