COL owner  FORMAT A15 
COL table_name  FORMAT A20 
COL CONSTRAINT_NAME  FORMAT A30 
COL constraint_source FORMAT A30 HEADING "Cons Name Table.Column"
COL references_column FORMAT A40 HEADING "Ref Table.Column"
 
BREAK ON owner ON TABLE_NAME ON constraint_name NODUP

SELECT   uc.owner,uc.table_name,uc.constraint_name, substr(uc.STATUS,1,1) ST, uc.constraint_type tipo, '('||ucc1.column_name||')' constraint_source
FROM     dba_constraints uc, dba_cons_columns ucc1
WHERE uc.owner = upper('&1') and ucc1.owner = upper('&1')
and uc.owner = ucc1.owner 
AND uc.constraint_name = ucc1.constraint_name
and ucc1.TABLE_NAME like upper('&2')
order by uc.owner,uc.table_name,uc.constraint_name,ucc1.POSITION;

SELECT   uc.owner,uc.table_name,uc.constraint_name, substr(uc.STATUS,1,1) ST, '('||ucc1.column_name||')' constraint_source, '('||ucc2.TABLE_NAME||'.'||ucc2.column_name||')' references_column
FROM     dba_constraints uc
,        dba_cons_columns ucc1
,        dba_cons_columns ucc2
WHERE uc.owner = upper('&1') and ucc1.owner = upper('&1')  and ucc2.owner = upper('&1')  
and uc.owner = ucc1.owner and uc.owner = ucc2.owner
AND uc.constraint_name = ucc1.constraint_name
AND      uc.r_constraint_name = ucc2.constraint_name
AND      ucc1.POSITION = ucc2.POSITION -- Correction for multiple column primary keys.
AND      uc.constraint_type = 'R'
and      (ucc1.TABLE_NAME like upper('&2'))
ORDER BY ucc1.TABLE_NAME, uc.constraint_name,ucc1.POSITION;

