Mysql – disabling and enabling foreign key checks

Recently I was working on a project in which I have to truncate tables in database. But due to foreign key constraints MySQL was throwing errors.
So the solution I found was to disable Foreign Key constraints temporarily delete all data and then again enable the foreign keys.

Disable foreign key checks.


Enable foreign key checks.


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.