Ref. http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_1037.htm
-- View The Relation of The Specific Table
col type format a10 col cons_name format a30 select decode(constraint_type, 'C', 'Check', 'O', 'R/O View', 'P', 'Primary', 'R', 'Foreign', 'U', 'Unique', 'V', 'Check view') type , constraint_name cons_name , status , last_change , R_CONSTRAINT_NAME , RELY from dba_constraints where owner like '&owner' and table_name like '&table_name' order by 1 /
-- View The PK column of The Specific Table
SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = '&table_name'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
AND cons.owner ='&owner'
ORDER BY cols.table_name, cols.position;
No comments:
Post a Comment