Home

Published

- 1 min read

cannot truncate a table referenced in a foreign key constraint

img of cannot truncate a table referenced in a foreign key constraint

The solution for this is noted below

cannot truncate a table referenced in a foreign key constraint

Solution

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

Try other methods by searching on the site. That is if this doesn’t work