MySQL: Cannot truncate a table referenced in a foreign key constraint …

fast trick:

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE tablename;
SET FOREIGN_KEY_CHECKS=1;

With these statements, you risk letting in rows into your tables that do not ad here to the foreign key constraints.

B logbook : PHP | Javascript | Laravel | CodeIgniter | VueJs | ReactJs | WordPress

Translate »