Thursday, March 28, 2013

MySQL - Cannot truncate a table referenced in a foreign key constraint

If you encounter the error "Cannot truncate a table referenced in a foreign key constraint", temporality turn off the foreign keys check like the following:

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE table;
SET FOREIGN_KEY_CHECKS=1;

No comments:

Post a Comment