简体   繁体   English

在 SQL Server 中查看表关系是否有特定的权限或用户设置?

[英]Is there a specific permission or user setting for viewing table relationships in SQL Server?

I was granted access to a SQL Server database and can connect and query the data.我被授予访问 SQL Server 数据库的权限,可以连接和查询数据。 However, I want to check for any explicit foreign keys and other relationships in the data model, but don't see any.但是,我想检查数据模型中的任何显式外键和其他关系,但没有看到任何内容。 I'm not sure if this is because there just aren't any defined, or a permissions issue, or an issue related to DataGrip.我不确定这是不是因为没有任何定义、权限问题或与 DataGrip 相关的问题。

What's odd is that in PowerBI, I can see a few relationships, but that might have been auto-generated when I connected to the database.奇怪的是,在 PowerBI 中,我可以看到一些关系,但这些关系可能是在我连接到数据库时自动生成的。

How do I know if my account was not granted permissions to view table relationships?我如何知道我的帐户是否未被授予查看表关系的权限? Here are the things that I can do right now:以下是我现在可以做的事情:

  • Query the data查询数据
  • Extract the DDL statement for any table within DataGrip.为 DataGrip 中的任何表提取 DDL 语句。

Not sure what else to try.不知道还能尝试什么。

You can try the following query.您可以尝试以下查询。

SQL数据库

SELECT OBJECT_NAME(f.parent_object_id) AS table_name  
    , f.name AS foreign_key_name  
    ,COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS constraint_column_name  
    ,OBJECT_NAME (f.referenced_object_id) AS referenced_object  
    ,COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) AS referenced_column_name  
   , [column_type] = t.name
    --,f.is_disabled, f.is_not_trusted
    --,f.delete_referential_action_desc  
    --,f.update_referential_action_desc  
FROM sys.foreign_keys AS f
   INNER JOIN sys.foreign_key_columns AS fkc   
      ON f.object_id = fkc.constraint_object_id
   LEFT JOIN sys.all_columns ac on fkc.referenced_object_id = ac.object_id 
      and fkc.referenced_column_id = ac.column_id
   INNER JOIN sys.types t on ac.system_type_id = t.system_type_id
--WHERE f.parent_object_id = OBJECT_ID('dbo.PropertySegment')
ORDER BY table_name; 

If you use the same account and can see the table relationships in the Power BI, but not in the Database Explorer of DataGrip, then it's unlikely to be a permission-related issue.如果你使用同一个账号,在Power BI中能看到表关系,但在DataGrip的Database Explorer中看不到,那么不太可能是权限相关的问题。 First, try to refresh the schema where these relationship objects are located.首先,尝试刷新这些关系对象所在的模式。 If the objects don't appear under the table when you expand the tree, please open a ticket.如果展开树时对象没有出现在桌子下面,请开工单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM