As part of testing Magento’s order workflow I needed to truncate the sales tables.
However, Mysql complained with the following error:
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint
However, by switching of foreign key check, I was able to truncate the table.
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE table1;
TRUNCATE table2;
SET FOREIGN_KEY_CHECKS=1;