清空具有外键约束的表时报ERROR 1701(42000)的解决
mysql> truncate table t_users;
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (`test`.`t_user_action`, CONSTRAINT `t_action_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `test`.`t_users` (`id`))
解决方法:
mysql> SET foreign_key_checks=0;
truncate table xxx;
truncate table xxx;
truncate table xxx;
……
mysql> SET foreign_key_checks=1;