Ich habe zwei Tabellen, und ich möchte HEDE2 Spalten als ausländische KEY REFERENCES von HEDE-Tabelle. Für die Erstellung einer zweiten Tabelle wird dies nicht erlaubt, da es eine Warnung hat:SQL Server: multi CASCADE Operation
Mehr als ein Schlüssel in Spalte Ebene FOREIGN KEY Einschränkung, Tabelle 'HEDE2' angegeben.
Aber wenn ich versuchte, für FOREIGN KEY ALTER TABLE HEDE2
es mir erlaubt, das zu tun. Weiß jemand, WARUM das passiert? Ist das ein Fehler?
CREATE TABLE cascde.HEDE
(
HedeID INT,
HedeID2 INT,
HedeID3 INT
CONSTRAINT PK_HEDE
PRIMARY KEY (HedeID, HedeID2, HedeID3)
)
GO
CREATE TABLE HEDE2
(
Hede2ID INT PRIMARY KEY IDENTITY(1,1) ,
HedeID INT,
HedeID2 INT,
HedeID3 INT
CONSTRAINT FK_HedeID
FOREIGN KEY (HedeID, Hede2ID, HedeID3)
REFERENCES cascde.HEDE (HedeID, HedeID2, HedeID3)
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
Änderung Tabelle HEDE 2 für Fremdschlüssel. Dies ermöglicht es mir zu tun, dass:
ALTER TABLE cascde.HEDE2
ADD CONSTRAINT FK_HEDE
FOREIGN KEY(HedeID, HedeID2, HedeID3)
REFERENCES cascde.HEDE (HedeID, HedeID2, HedeID3)
ON UPDATE NO ACTION
ON DELETE NO ACTION
GO
Danke @cynic für Hilfe. Es funktionierte. – cunay