Oracle数据库触发器数据库审计

一 需求

数据库的审计——基于值得审计功能
当涨后的薪水超过6000时,审计该员工信息

二 代码
  1. --触发器应用场景3:数据库的审计,基于值得审计
  2. --给员工涨工资,当涨后的薪水超过6000时,审计该员工信息
  3. --创建表,用于保存审计信息
  4. /*
  5. create table audit_info
  6. (
  7. information varchar2(200)
  8. );
  9. */
  10. create or replace trigger do_audit_emp_salay
  11. after update
  12. on emp
  13. for each row
  14. begin
  15. if:new.sal >6000then
  16. insert into audit_info values(:new.empno||' '||:new.ename||' '||:new.sal);
  17. endif;
  18. end;
 
三 验证
SQL> select * from audit_info;
 
INFORMATION
--------------------------------------------------------------------------------
7566 JONES 9075
7698 BLAKE 8850
7782 CLARK 8450
7788 SCOTT 7000
7839 KING 12101
7902 FORD 7000
 
已选择6行。

猜你喜欢

转载自cakin24.iteye.com/blog/2390336