tags:

views:

57

answers:

2

Hi,

I plan to delete data from a table, i would like to know how many and which tables have a foreign key reference to this particular table in Oracle. As i will have to set the foreign keys to null. I would like to know list of all tables which have a FK to this particular table.

+2  A: 
select d.table_name,

       d.constraint_name "Primary Constraint Name",

       b.constraint_name "Referenced Constraint Name"

from user_constraints d,

     (select c.constraint_name,

             c.r_constraint_name,

             c.table_name

      from user_constraints c 

      where table_name='EMPLOYEES' --your table name instead of EMPLOYEES

      and constraint_type='R') b

where d.constraint_name=b.r_constraint_name
kupa
A: 

There is no need to do this step manually - you can just use a cascading delete.

Gaius