Related child tables

September 3rd, 2012

All child tables related to a parent table name

SELECT
    p.table_name  PARENT_TABLE_NAME
  , c.table_name  CHILD_TABLE
FROM
    all_constraints  p
  , all_constraints  c
WHERE
    (p.constraint_type = 'P' OR p.constraint_type = 'U')
    AND
    (c.constraint_type = 'R')
    AND
    (p.constraint_name = c.r_constraint_name)
    AND
    (p.table_name = UPPER('&TABLE_NAME'))
ORDER BY 2
/


Comments are closed.