Reputation: 47
BranchNAME should be not null and can have any one of the listed values (Chennai, Mumbai,Delhi,Bangalore)
I can put single name in check how to put all cities names in check.
ALTER TABLE Employee ADD CONSTRAINT Branch CHECK (Branch= 'Delhi');
Upvotes: 0
Views: 588
Reputation:
Use an IN
condition:
ALTER TABLE Employee ADD CONSTRAINT check_branch_name
CHECK (Branch IN ('Delhi','Chennai','Mumbai','Bangalore'));
and don't forget to add not null
constraint
ALTER TABLE EMPLOYEE MODIFY BRANCH not null;
if not exists.
Upvotes: 3