SELECT RPAD(child.TABLE_NAME,25, ) Child_Tablename,
RPAD(cp.COLUMN_NAME,17, ) Referring_Column,
RPAD(parent.TABLE_NAME,25, ) Parent_Tablename,
RPAD(pc.COLUMN_NAME,15, ) Referred_Column,
RPAD(child.CONSTRAINT_NAME,25, ) Constraint_Name
FROM USER_CONSTRAINTS child,
USER_CONSTRAINTS parent,
USER_CONS_COLUMNS cp,
USER_CONS_COLUMNS pc
WHERE child.CONSTRAINT_TYPE = R AND
child.R_CONSTRAINT_NAME = PARENT.CONSTRAINT_NAME AND
child.CONSTRAINT_NAME = cp.CONSTRAINT_NAME AND
parent.CONSTRAINT_NAME = pc.CONSTRAINT_NAME AND
cp.POSITION = pc.POSITION
ORDER BY child.OWNER,
child.TABLE_NAME,
child.CONSTRAINT_NAME,
cp.POSITION. |