清空具有外键约束的表时报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;

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2021-10-23
  • 2021-10-30
  • 2021-12-18
  • 2021-09-17
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-09-24
  • 2021-11-24
相关资源
相似解决方案