How to Create CHECK Constraint in SQL
In this article I am going to explain about CHECK Constraints in SQL.
If you want to limit the value that are accepted by a column use CHECK constraint. Check constraint have some similarities like FOREIGN Key constraint because both constraint control the value that are entered in column.
Using CHECK constraint you can limit the range of value entered in salary column. You can set range for salary from 10000 through 1000000 using it.
Statement that create a CHECK constraint in empinfo table
create table empinfo
empid int primary key,
emp_panno int unique,
CHECK(salary >=10000 and salary <=1000000)
Statement that use empinfo table