select p.table_name as parent_table,
pc.column_name as parent_table_column,
C.Table_Name As Child_Table,
Cc.Column_Name As Child_Table_Column ,
C.R_Constraint_Name As Parent_Constraint_Name,
c.constraint_name as child_constraint_name
from user_constraints p, user_constraints c,
user_cons_columns pc, user_cons_columns cc
where p.constraint_name = c.r_constraint_name
and p.constraint_name = pc.constraint_name
and pc.position = cc.position
and c.constraint_name = cc.constraint_name
and c.table_name = 'table name';
There are two types of researchers. Those who have done something and those who haven't. The latter will say there are 143 ways to do something, and the former will say 142 of them don't work. - Quote from a System V researcher
Wednesday, August 12, 2009
SQL Sinppet : Parent/Child tables
SQL to find out foreign key relationships between tables