Link to home
Start Free TrialLog in
Avatar of edwardsearch
edwardsearch

asked on

list Table Constraints

how to view one particular table constraints in oracle
For example i want to view all primary,unique,integrity constraints in emp table
ASKER CERTIFIED SOLUTION
Avatar of kamal_therocky
kamal_therocky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kamal_therocky
kamal_therocky

Hi,

The Constraint_type column in those data dictionary is used to determine the type of constraint.

P - Primary Key
U - Unique Key

so you write

Select * from all_constraints
where table_name = 'EMP'
and Constraint_Type in ('P','U');

Thanks
kamal
Avatar of awking00
To get both,
select constraint_name
from all_constraints a
where table_name = 'EMP'
and constraint_type = 'P'
and exists
(select 1
 from all_constraints b
 where table_name = 'EMP'
 and constraint_type = 'U'
 and a.constraint_name = b.constraint_name);