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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: foreign key constraints

RE: foreign key constraints

From: Guy Hammond <guy.hammond_at_avt.co.uk>
Date: Tue, 21 Aug 2001 08:41:27 -0700
Message-ID: <F001.003724D7.20010821074133@fatcity.com>

Actually, I have it:

select a.table_name, b.table_name, b.column_name, c.column_name from user_constraints a, user_cons_columns b, user_cons_columns c where

a.r_constraint_name = b.constraint_name and a.constraint_name =
c.constraint_name and b.column_name != c.column_name  and
a.constraint_type='R';

:0)

g

> -----Original Message-----
> From: Guy Hammond
> Sent: Tuesday, August 21, 2001 2:44 PM
> To: 'oracle-l_at_fatcity.com'
> Subject: foreign key constraints
>
> Let's say I had two tables:
>
> CREATE TABLE t1 (
> col1 NUMBER PRIMARY KEY);
>
> CREATE TABLE t2 (
> col2 REFERENCES t1(col1),
> col3 VARCHAR2(40));
>
>
> Then I ran the query:
>
> select a.table_name, b.table_name, b.column_name from user_constraints
> a, user_cons_columns b where a.r_constraint_name = b.constraint_name
> and a.constraint_type='R';
>
> I will get back a result set containing
>
> a.table_name = t2
> b.table_name = t1
> b.column_name = col1
>
> But what query would I run to find "col2"?
>
> Thanks,
>
> g
>
>
>
> --
> Guy Hammond
> AVT Technologies
> 12-16 Westland Place
> London N1 7LP UK
>
> Email: guy.hammond_at_avt.co.uk
> Office: +44 (0) 207 454 1224
> Mobile: +44 (0) 7966 164687
>

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Guy Hammond
  INET: guy.hammond_at_avt.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Aug 21 2001 - 10:41:27 CDT

Original text of this message

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