分类: MySQL

mysql清空具有外键约束的表时报ERROR 1701(42000)的解决

truncate table JBPM4_DEPLOYMENT;
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (zhongjian_jbpm.JBPM4_DEPLOYPROP, CONSTRAINT FK_DEPLPROP_DEPL FOREIGN KEY (DEPLOYMENT_) REFERENCES zhongjian_jbpm.JBPM4_DEPLOYMENT (DBID_))
解决方法:

SET foreign_key_checks=0;
truncate table JBPM4_DEPLOYMENT;
......
SET foreign_key_checks=1;

发表新评论