Constraint-related SQL queries
The following tables are needed to retrieve Oracle constraint information.
Find constraint reference table.
- user_constraints / dba_constraints
- user_cons_columns / dba_cons_columns
all_constraints
--find constraint by name...select a.table_name , a.constraint_name , a.constraint_type , b.table_name , b.column_name , b.positionfrom user_constraints a , user_cons_columns bwhere a.constraint_name = 'POT_MLOC_FK'Find constraint reference table.
--find maint_diag table as constraint in other tables ("referended table")select owner,constraint_name,constraint_type,table_name,r_owner,r_constraint_name from all_constraints where constraint_type='R' and r_constraint_name in (select constraint_name from all_constraints where table_name='MAINT_DIAGNOSIS');

Comments