Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL to View Table Relationships?
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