[英]SQL Oracle query Constraint
BranchNAME should be not null and can have any one of the listed values (Chennai, Mumbai,Delhi,Bangalore) BranchNAME不能为空,并且可以具有所列值之一(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');
Use an IN
condition: 使用
IN
条件:
ALTER TABLE Employee ADD CONSTRAINT check_branch_name
CHECK (Branch IN ('Delhi','Chennai','Mumbai','Bangalore'));
and don't forget to add not null
constraint 并且不要忘记添加
not null
约束
ALTER TABLE EMPLOYEE MODIFY BRANCH not null;
if not exists. 如果不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.