Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL to View Table Relationships?

Re: SQL to View Table Relationships?

From: hazledid <david.hazledine_at_roche.com>
Date: Fri, 23 Jul 1999 15:41:13 GMT
Message-ID: <t20m3.4525$J5.47827@c01read02-admin.service.talkway.com>


On 23 Jul 1999 06:10:13 -0400 "Scott Murray" <smurray_at_officecomp.com> wrote:
> I am stumped trying to display the relationships between tables (i.e.,
> which tables have foreign keys to which tables).

You need to use the USER_CONSTRAINTS view. The following query should give you the general idea.

select child.table_name child_table, child.constraint_name foreign_key, parent.table_name parent_table
from user_constraints child, user_constraints parent where child.constraint_type = 'R' -- These are foreign key constraints where type = 'R'
and child.r_owner = parent.owner
and child.r_constraint_name = parent.constraint_name ;

David J. Hazledine
Roche Products Limited
40 Broadwater Road
Welwyn Garden City
AL7 3AY
United Kingdom
Registration Number 100674

E-mail: david.hazledine_at_roche.com
Fax: +44 (0)1707 325666
Tel: +44 (0)1707 366166
--
Posted via Talkway - http://www.talkway.com Exchange ideas on practically anything (tm). Received on Fri Jul 23 1999 - 10:41:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US