首页 > 代码库 > sql查询指定表外键约束
sql查询指定表外键约束
//////////////////查询指定表外键约束
selecta.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 Ainner join sys.foreign_key_columns B on A.object_id=b.constraint_object_idinner 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查询指定表外键约束
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。