Check Constraint

 Check Constraint

Check Constraint : – Check constraint check the condition which is specify on the column that must be TRUE.


1) Check Constraint (Column Level) :-


a) With System defined name


SQL>create table student(regno number(10), name varchar2(10),dob date,course varchar2(10) check (course in ('MCA','BCA')));


b) With User defined name


SQL>create table student(regno number(10), name varchar2(10),dob date,course varchar2(10) constraint ck_course check (course in ('MCA','BCA')));


2) Check Constraint (Table Level) :-


a) With System defined name


SQL>create table student(regno number(10),name varchar2(10),dob date,course varchar2(10), check (course in ('MCA','BCA')));


b) With User defined name


SQL>create table student(regno number(10),name varchar2(10),dob date,course varchar2(10),constraint ck_course check (course in ('MCA','BCA')));


3) Composite Check Constraint :-Check constraint defined for more than one column is called Composite Check Constraint.


a) With System defined name


SQL>create table student(regno number(10),name varchar2(10),dob date,course varchar2(10),check (course in ('MCA','BCA') and regno>1000));


b) With User defined name


SQL>create table student(regno number(10),name varchar2(10),dob date,course varchar2(10), constraint ck_regno check (course in ('MCA','BCA') and regno>1000));

                  

--------------------------HAPPY LEARNING -----------------------------


                                                                                                   **THANK YOU**

No comments:

Post a Comment