码迷,mamicode.com
首页 > 数据库 > 详细

sql查询指定表外键约束

时间:2017-07-15 22:43:10      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:parent   rom   enc   str   object_id   主键   查询   reference   join   

//////////////////查询指定表外键约束
select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.referenced_object_id) as 主健表, c.name as 主键列 from sys.foreign_keys A inner join sys.foreign_key_columns B on A.object_id=b.constraint_object_id inner join sys.columns C on B.parent_object_id=C.object_id and B.parent_column_id=C.column_id inner join sys.columns D on B.referenced_object_id=d.object_id and B.referenced_column_id=D.column_id where object_name(B.referenced_object_id)=‘要查询的表名‘;

sql查询指定表外键约束

标签:parent   rom   enc   str   object_id   主键   查询   reference   join   

原文地址:http://www.cnblogs.com/yexiaoyanzi/p/7185565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!