Luo Hao

Oracle实践数据库笔记-11

Rehoni / 2018-04-08


审核

    desc dbms_fga;---STATEMENT_TYPES审核语句类型
    execute dbms_fga.add_policy('SCOTT','EMP','FGA_DEMO',STATEMENT_TYPES=>'SELECT,INSERT,DELETE');
    ---执行select,insert,delete操作
    desc dba_fga_audit_trail
    alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
    ---中间进行scott用户下的select,insert和delete操作
    select TIMESTAMP,DB_USER,SQL_TEXT from dba_fga_audit_trail
    show parameter audit

触发器(头部,触发条件,被触发代码)

    create table demo1(a varchar(20));
    create or replace trigger scott.tr1
    after update on scott.emp for each row
    begin
    	insert into scott.demo1 values('changed!');
    end;
    update emp set sal=2000 where empno=7369;
    select * from demo1;
    create or replace trigger scott.tr1
    after update on scott.emp referencing old as o new as n for each row when(n.sal>5000)
    begin
    	insert into scott.demo1 values('changed!');
    end;

创建一个工资表, 用触发器实现更改工资之后, 显示旧的工资和新的工资的变化🆗

    create table sal_change(empno number(4),ename varchar2(10), old_sal number(7,2), new_sal number(7,2));
    create or replace trigger scott.tr1
    after update on scott.emp referencing old as o new as n for each row
    begin
      insert into scott.sal_change values(:o.empno, :o.ename,:o.sal,:n.sal);
    end;
    update emp set sal=4000 where empno=7902;
    select * from sal_change;

移动数据