为什么我的团队中没有TRUNCATE?即使我有一个删除级联集,我得到:
错误1701(42000):无法截断外键约束(mytest.instance,constraint instance_ibfk_1 foreign key(GroupID)REFERENCES mytest.mygroup(ID))中引用的表
drop database mytest;
create database mytest;
use mytest;
CREATE TABLE mygroup (
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
CREATE TABLE instance (
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
GroupID INT NOT NULL,
DateTime DATETIME DEFAULT NULL,
FOREIGN KEY (GroupID) REFERENCES mygroup(ID) ON DELETE CASCADE,
UNIQUE(GroupID)
) ENGINE=InnoDB;