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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple question re Foreign key info

Re: Simple question re Foreign key info

From: Stephen Bell <stephen.bell_at_cgi.ca>
Date: Tue, 14 Aug 2001 10:42:54 -0400
Message-ID: <fQae7.19530$P87.1818776@news20.bellglobal.com>


Hi,

One way is to select from USER_CONSTRAINTS (or DBA_CONSTRAINTS if it's appropriate and if you have
access to it) like this for example:

SQL> select constraint_name,table_name,r_constraint_name   2 from user_constraints
  3 where table_name in ('EMP','DEPT') AND   4 CONSTRAINT_TYPE = 'R';

CONSTRAINT_NAME                TABLE_NAME
R_CONSTRAINT_NAME
------------------------------ ------------------------------ --------------
----
EMP_SELF_KEY                   EMP
EMP_PRIMARY_KEY
EMP_FOREIGN_KEY                EMP

DEPT_PRIMARY_KEY Further you can select from USER_CONS_COLUMNS to get information on which columns the constraints
apply to.

I hope this helps,

Steve

"Twin" <tweeting100_at_hotmail.com> wrote in message news:997798648.13978_at_ernani.logica.co.uk...
> Hi all,
>
> I've always wanted to know how to do this, but no-one seems to be able to
> tell me how.
>
> I have three tables (tablea, tableb and tablec) related in someway to each
> via foreign keys. I don't have the script to see the relationships, so
I'd
> like to know which system table contains the foreign key relationships (if
> any).
>
> Any ideas ?
>
> Thanks.
>
>
Received on Tue Aug 14 2001 - 09:42:54 CDT

Original text of this message

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