我有以下问题,我有一个表,其中包含来自唯一列的两个外键,如下所示:
注意: id_maquina_camino是“唯一的”,并且需要两个表格。
如果我添加外键一切顺利,但当我尝试在级联上添加删除时出现错误:
Msg 1785, Level 16, State 0, Line 11
Introducing FOREIGN KEY constraint 'FK__camino__destino__300424B4' on table 'camino' 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 11
Could not create constraint. See previous errors.
代码:
ALTER TEST.dbo.camino
ADD FOREIGN KEY (origen)
REFERENCES maquina (id_maquina_camino)
ON DELETE CASCADE;
ALTER TEST.dbo.camino
ADD FOREIGN KEY (origen)
REFERENCES maquina (id_maquina_camino)
ON UPDATE CASCADE;
ALTER TEST.dbo.camino
ADD FOREIGN KEY (destino)
REFERENCES maquina (id_maquina_camino)
ON DELETE CASCADE;
ALTER TEST.dbo.camino
ADD FOREIGN KEY (destino)
REFERENCES maquina (id_maquina_camino)
ON UPDATE CASCADE;