资源预览内容
第1页 / 共5页
第2页 / 共5页
第3页 / 共5页
第4页 / 共5页
第5页 / 共5页
亲,该文档总共5页全部预览完了,如果喜欢就下载吧!
资源描述
1. 在 emp 表上创建一个触发器,保证每天 8:00-17:00 之外的时间禁止对该表进行 DML 操作。create or replace trigger tr_emp_workbefore insert or update or delete on empdeclarea varchar2(50);n number;beginselect to_char(sysdate,hh24) into n from dual;if n17 thenraise_application_error(-20002,禁止在八点前五点后修改数据);end if;end;2.在 emp 表上创建一个触发器,当插入、删除或修改员工信息时,统计各个部门的人数及平均工资,并输出。CREATE OR REPLACE TRIGGER trg_empAFTER INSERT OR UPDATE OR DELETE ON EMPDECLAREv_sal emp.sal%type;v_count number;BEGINSELECT AVG(SAL),COUNT(*) INTO V_SAL,V_COUNT FROM EMP;DBMS_OUTPUT.PUT_LINE(V_SAL| |V_COUNT);END;3.在 emp 表上创建一个触发器,保证修改员工工资时,修改后的低于该部门最高工资,同时高于该部门最低工资。create or replace trigger pk_emp before insert or update on emp for each rowdeclarev_max number(6);v_min number(6);beginselect max(sal) into v_max from emp ;select min(sal) into v_min from emp;if :new.sal v_max and :new.sal v_max and :new.sal v_highsal or pkg_deptno.v_salv_lowsal THENRAISE_APPLICATION_ERROR(-20001,THE SAL IS BEYOND!);END IF;END;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号