Tuesday, October 8, 2013

how to know the constraints on table in oracle..............

select * from user_cons_columns ucc, user_constraints uc 
where uc.constraint_name=ucc.constraint_name
and uc.constraint_type='P' and uc.table_name = 'Table Name';
R = Referential Constraint/Foreign Key constraint
C = Check Constraint
P = Primary Key
U = Unique Key

(or)

select 
   cons.owner            as child_owner, 
   cons.table_name       as child_table,
   cons.constraint_name     constaint_name,
   cons.constraint_type     constraint_type,
   col.owner                parent_owner, 
   col.table_name           parent_table,
   col.column_name          column_name
from dba_cons_columns      col, 
     dba_constraints       cons
where 
   cons.r_owner = col.owner
and 
   cons.r_constraint_name = col.constraint_name
and 
   cons.table_name = 'Table Name';
   
(or)


   select * 
from
    all_constraints 
where
    r_constraint_name in
    (select       constraint_name
    from
       all_constraints
    where
       table_name='Table Name') 

1 comment:

  1. A CONSTRAINT clause can constrain a single column or group of columns in a table.
    We are providing the Professional Junk Removal Services in Baltimore, MD We sort all of the junk that we accumulate so that we can responsibly recycle.

    ReplyDelete