[英]check statement add constraint
create table sallaary(创建表工资(
E_ID number (10) ,
bank_type varchar(10),
creditcardnumber number(12) primary key ,
bonus number(5),
salary_date date ,
work_hours number (3),
constraint check_hours check (work_hours > 40 )
constraint sallary2_emp_fk foreign key (E_ID) references salloonee_employee1
); );
Now, this is my code.现在,这是我的代码。 The idea of the first constraint "check_hours " is to add a bonus to the employee if his work hours exceeded 40 hours but I don't know how to write it第一个约束“check_hours”的想法是如果员工的工作时间超过 40 小时,则给他加分,但我不知道如何写
Note: the first constraint "check_hours " is not complete注意:第一个约束“check_hours”不完整
Hmmm.嗯。 . . . . I think you want a bonus
when the hours exceeds 40. If so:我认为你想要超过 40 小时的bonus
。如果是这样:
constraint check_hours check (not (bonus = 0 and work_hours > 40))
Or equivalently:或等效地:
constraint check_hours check (bonus > 0 or work_hours <= 40)
Or, if bonus
can be NULL
:或者,如果bonus
可以是NULL
:
constraint check_hours check (not (coalesce(bonus, 0) = 0 and work_hours > 40))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.