gpt4 book ai didi

sql - 在 SSMS 20114 中添加新外键引用时,数据库图表不显示表关系

转载 作者:行者123 更新时间:2023-12-02 04:03:03 26 4
gpt4 key购买 nike

我有如下三个表 -

enter image description here

但是当我添加外键引用时,关系(数据库图中的一条直线)未显示

以下是我写的引用资料。

ALTER TABLE [dbo].EmployeeDesignation   
ADD CONSTRAINT FK_EmployeeDesignation_Employee FOREIGN KEY (EmployeeId)
REFERENCES Employee (EmployeeId)
ON DELETE CASCADE
ON UPDATE CASCADE
;

ALTER TABLE [dbo].[EmployeeDesignation]
ADD CONSTRAINT FK_EmployeeDesignation_Designation FOREIGN KEY (DesignationId)
REFERENCES Designation (DesignationId)
ON DELETE CASCADE
ON UPDATE CASCADE
;

此外,当我添加另外两个表(Department 和 EmployeeDepartment)时,我可以在图中看到关系 enter image description here

引用代码如下——

ALTER TABLE [dbo].EmployeeDepartment     
ADD CONSTRAINT FK_EmployeeDepartment_Department FOREIGN KEY (DepartmentId)
REFERENCES Department (DepartmentId)
ON DELETE CASCADE
ON UPDATE CASCADE
;

ALTER TABLE [dbo].EmployeeDepartment
ADD CONSTRAINT FK_EmployeeDepartment_Employee FOREIGN KEY (EmployeeId)
REFERENCES Employee (EmployeeId)
ON DELETE CASCADE
ON UPDATE CASCADE
;

后一个显示关系线而前一个不显示可能是什么原因?我错过了什么吗?

谢谢!

最佳答案

尝试关闭 SSMS,然后重新打开它。似乎 SSMS 用于某些功能的缓存即使在关闭并重新打开数据库连接时也不会刷新。检查https://stackoverflow.com/a/4316415/364084

关于sql - 在 SSMS 20114 中添加新外键引用时,数据库图表不显示表关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40970941/

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