/*触发器应用场景三: 数据的审计---》基于值得审计功能 例子:给员工涨工资,当涨后的薪水超过6000块时候,审计该员工的信息 创建表,用于保存审计信息 */ create table outdit_info(inforoudname VARCHAR2(2000)); create or replace trigger outdit_emp_sal_tri after UPDATE on EMP for each row BEGIN IF :new.sal > 6000 THEN insert INTO outdit_info VALUES (:new.EMPNO||' '||:new.ename||' '||:new.sal); end if; END; UPDATE emp set sal = sal + 3000;
触发器案例三:数据库的审计功能
基于值的审计功能
给员工涨工资,当涨后的薪水超过6000块前时候,审计员工的信息。
/*创建表,用于保存审计信息*/
create table audit_info
(
information varchar2(200)
);
create or replace trigegr do_audit_emp_salary
after update
on emp
for each row
begin
/*当涨后的薪水大于6000,插入审计信息*/
if :new.sal > 6000 then
insert into audit_info_values(:new.empno||' '||:new.ename||' '||:new.sal);
end if;
end;
数据审计:当数据大于指定值时,插入审计信息
create or replace trigger trg
after update
on table
for each row
begin
if :new.sal>6000 then
insert into table1 values();
end if;
end;
/
触发器:数据库审计(基于值的审计功能,行级触发器)

触发器使用场景:基于值的审计功能
数据库的审计 -->基于值的审计
create table audit_info
(
information varchar2(200)
);
create or replace trigger do_audit_emp_salary
after update
on emp
for each row
begin
if :new.sal > 6000 then
insert into audit_info value (:new.empno||' '||:new.ename||' '||:new.sal);
end if;
end;
/
数据库审计功能场景
3、数据的审计

触发器之审计功能:
