[Back To HomePage and Script Library]

Disclaimer: Use these scripts and/or any recommendations they may contain at your own risk. These scripts may or may not have been tested.

Title: Checking Parent Columns for Child Table,R_Constraints

Author: Quan Yang, a DBA for INS in Arlington, Virignia.

The script displays the columns of the parent table for its child foreign keys.
Source/Text/Comments


****Display the requested information based on child table

****name provided



select a.table_name parent_table,

       a.column_name parent_column,

       b.table_name child_table,

       b.column_name child_column,

       b.constraint_name

  from user_cons_columns a,

       user_cons_columns b,

       user_constraints c

  where b.table_name ='&child_table_name' and

        a.constraint_name = c.r_constraint_name and

        b.constraint_name =c.constraint_name;







****Display the requested information based on constraint

****name provided



select a.table_name parent_table,

       a.column_name parent_column,

       b.table_name child_table,

       b.column_name child_column,

       b.constraint_name

  from user_cons_columns a,

       user_cons_columns b,

       user_constraints c

  where b.constraint_name ='&constraint_name' and

        a.constraint_name = c.r_constraint_name and

        b.constraint_name =c.constraint_name;