无法截断外键约束中引用的表.
我应该先做什么才能启用trancate?
ditails:
(guacamole.guacamole_connection_history,CONSTRAINT guacamole_connection_history_ibfk_2 FOREIGN KEY(connection_id)REFERENCES guacamole.guacamole_connection(connection_id))
我想清除guacamole_connection表进行开发测试.
最佳答案
为什么不添加一个约束添加ON DELETE CASCADE和ON UPDATE CASCADE?然后你需要做的就是TRUNCATE guacamole_connection CASCADE
原文链接:https://www.f2er.com/mysql/434123.html例:
ALTER TABLE guacamole_connection_history ADD CONSTRAINT guacamole_connection_history_cascade_delete FOREIGN KEY(connection_id)REFERENCES guacamole_connection(connection_id)ON UPDATE CASCADE ON DELETE CASCADE;
然后只需运行TRUNCATE guacamole_connection CASCADE