Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Report for Extracting Primary and dependant Foreign Keys for a table.
Hi, Ken Geng!
> > Does anyone wish to share a script they may have, to identify
> > all Foreign keys for a particular Primary key.
>
>
> SELECT CONSTRAINT_NAME FROM ALL_CONSTRAINTS
> WHERE R_CONSTRAINT_NAME = 'PK_????';
>
It's incorrect.
I may named constraints 'Beer_???' or 'Wine_???'.
:-)
I use:
select t1.TABLE_NAME, t2.column_name , T3.TABLE_NAME, t4.column_name
from user_constraints t1,user_cons_columns t2,
user_constraints t3,user_cons_columns t4 where t1.table_name = :Table_name
and t1.constraint_type='R' and t1.constraint_name= t2.constraint_name and t1.r_constraint_name= t3.constraint_name and t1.R_constraint_name= t4.constraint_nameORDER BY T4.CONSTRAINT_NAME, T4.position;
---
Miroslav Narodecky. miroslav_at_percombank.kiev.ua
Received on Thu Apr 03 1997 - 00:00:00 CST