+1 vote
in Class 12 by kratos

Explain with example to create details of employees and give the minimum and maximum in the salary domain.

1 Answer

+5 votes
by kratos
 
Best answer

The CHECK constraint is used to limit the value range that can be placed in a column.
If you define a CHECK constraint on a single column it allows only certain values for this column.

Check Constraint at column level:
CREATE TABLE employee
( id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
gender char(l),
salary number(lO) CHECK (salary >= 5000 AND salary <= 40000),
location char(10)

*);
In the above example, the salary column is defined as a number column with a check constraint. It checks constraint checks the value that can be stored in the salary column should be greater than or equal to 5000 which is the minimum value and the value is less than or equal to 40000 which is the maximum value for the column salary.

...