gpt4 book ai didi

sql-server - SQL 更改 : add multiple FKs?

转载 作者:行者123 更新时间:2023-12-02 15:43:32 25 4
gpt4 key购买 nike

From here

ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);

如何使用 SQL Server 添加多个键?是像下面这样的吗? (我无法测试 ATM,不幸的是我无法测试查询,除非我通过代码运行它)

ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID),
ADD FOREIGN KEY (customer_sid2) REFERENCES CUSTOMER(SID2);

或者是这样的

ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid, customer_sid2) REFERENCES CUSTOMER(SID, SID2)

最佳答案

ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID),
FOREIGN KEY (customer_sid2) REFERENCES CUSTOMER(SID2),
FOREIGN KEY (customer_sid3) REFERENCES CUSTOMER(SID3);

关于sql-server - SQL 更改 : add multiple FKs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2865662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com