Oracle Database Triggers Database Auditing

a need

Auditing of Databases - Based on Worth Auditing Functions
When the salary increase exceeds 6,000, audit the employee's information

two code
  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;
 
Three verification
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 rows are selected.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326955525&siteId=291194637