开发者

SQL 2008 Management Studio-- where to find table relationships?

开发者 https://www.devze.com 2022-12-10 07:47 出处:网络
I\'m brand new to SQL Server 2008, and have some newbie questions about the diagram pane.I just dragged two tables onto it to do an inner join, and the console \"knew\" to create a one-to-many relatio

I'm brand new to SQL Server 2008, and have some newbie questions about the diagram pane. I just dragged two tables onto it to do an inner join, and the console "knew" to create a one-to-many relationship between them. Where is this information kept in the Management Studio 开发者_如何学JAVAfor me to look at closer?

Thanks!


Much of this information is actually available in system tables in the database containing the user tables.

Here are two of the available tables of interest. sys.tables contains table information, sys.foreign_keys contains relationship information via foreign key constraints.

sys.tables (Transact-SQL) @ MSDN
sys.foreign_keys (Transact-SQL) @MSDN

Also handy is the following information on Pinal Dave's site on using this information for your own lookups.

Find tables with Foreign Key Constraint in Database @ SQLAuthority.com
Find Relationship of Primary key and Foreign Key using T-SQL @ SQLAuthority.com


One of the tables has a foreign key referencing the other table. In Object Explorer, expand the information for the tables involved and look under Keys.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号