清空具有外鍵約束的表時報ERROR 1701(42000)
Cannot truncate a table referenced in a foreign key constraint (`laravel-test`.`bl_role_user`, CONSTRAINT `role_user_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `laravel-test`.`bl_roles` (`id`))
解決的辦法:
關閉外鍵約束->清空表->啟動外鍵約束。
例子:
mysql> SET foreign_key_checks=0;
mysql> truncate table bl_roles;
mysql> SET foreign_key_checks=1;