create table employee
(
eid int primary key,
ename varchar(50),
cid int,
sid int,
constraint fk_hello1 foreign key(cid) references country(cid)on delete
cascade on update cascade,
constraint fk_hello2 foreign key(sid) references state(sid) on delete
cascade on update cascade,
)
我一直在尝试应用此代码,但我不断收到错误消息.........
ERROR MESSAGE
Msg 1785, Level 16, State 0, Line 1
Introducing FOREIGN KEY constraint 'fk_hello2' on table 'employee' may
cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or
ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
答案 0 :(得分:2)
在数据库结构中的关系中有循环引用时,不能使用on update cascade
:
仅允许NO ACTION
(请参阅错误Specify ON DELETE NO ACTION or
ON UPDATE NO ACTION
)
来自国家的州是否具有与员工不同的含义?
和表[Employee]必须在多列上有一个外键 - FK(CID,SID)