Cannot truncate a table referenced in a foreign key constraint mysql error

Trying to update the schema or truncating the table or something else and got this error?
Turn the constraint temporarily and the issue shall be fixed:

SET FOREIGN_KEY_CHECKES=0;
TRUNCATE TABLE somepoortable;
.
.
SET FOREIGN_KEY_CHECKS=1;

That is it!

Leave a Reply

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

*
*