暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

How do I list the parent tables, and relevant columns for a table at the child end of a foreign key constraint ?

2011-01-01
601

The Oracle (tm) Users' Co-Operative FAQ

How do I list the parent tables, and relevant columns for a table at the child end of a foreign key constraint .


Author's name: William O'Reilly

Author's Email: boreilly@att.com

Date written: 2nd November, 2001

Oracle version(s): 8.1

How do I list the parent tables, and relevant columns for a table at the child end of a foreign key constraint .


The following script will list all parent/child relationships, givng the column names at the parent end of the relation in the correct order.

-- Parent / Child / Key Reference --
set pages 50000
set feedback off
spool constraint.log
col parent format a27
col child  format a27
col key    format a21
select a.table_name         Parent,
       b.table_name         Child,
       column_name          Key,
       substr(position,1,1) P
from 
      user_constraints a, user_constraints b, user_cons_columns c
where 
      a.constraint_name = b.r_constraint_name
and   a.constraint_name = c.constraint_name
order by 1, 2, 4;
spool off

Further reading: N/A



最后修改时间:2020-04-16 15:12:11
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论