Constraints are used to prevent in valid data entry into our tables.Constraints are created on table columns.Oracle server supports following types
1)not
null
2)unique
3)primary
key
4)foreign
key
5)check
All
the above constraints are defined in 2 levels
i)column
level
ii)table
level
I)All
constraints information stored under user_constraints(data
dictionary)
SQL>desc
user_constraints
Query:select
constraint_type,constraint_name from user_constraints where
table_name='EMP';(EMP should be capital)
II)If
we want to view constraint names along with column names we are using
USER_CONS_COLUMNS.
SQL>desc
user_cons_columns
Query:select
constraint_type,column_name from user_cons_columns where
table_name='EMP';
III)If
we want to view logical condition of the check constraint we are
using search_condition property from user_contraints
SQL>desc
user_constraints;
Query:select
constraint_name,constraint_type,search_condition from
user_constraints where table_name='EMP';
Great & Useful Article
ReplyDeleteOnline Java Training
Online Java Training From India