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: foreign keys

Re: foreign keys

From: Stephan Schaefer <stephan.schaefer_at_camline.com>
Date: 1998/03/03
Message-ID: <34FBCA77.9E5E11A9@camline.com>#1/1

Ed Lufker wrote:

> What select statement would I use to see if there are any foreign
> keys on a table.

Hello Ed,

select *
from user_constraints
where Constraint_Type = 'R'
  and Table_name = 'MYTABLE'
;

To see my constraints by column names I use:

column "Constraint" format A20
column "Table" format A44
column "Column" format A44

select distinct
  c.constraint_name "Constraint",
  c1.table_name ||'->'||c2.table_name "Table",   c1.column_name || '->' || c2.column_name "Column" from

  user_cons_columns c1,
  user_cons_columns c2,
  user_constraints c

where c.constraint_name = c1.constraint_name   and c.r_constraint_name = c2.constraint_name   and c1.position = c2.position
;

Stephan Received on Tue Mar 03 1998 - 00:00:00 CST

Original text of this message

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