创建日志表记录DML操作和DDL操作

创建一个日志表,记录dept表的DML操作

create table dept_log(logid number,type varchar2(50),logdate date,deptno number,dname varchar2(50),loc varchar2(50));

create sequence dept_log_seq;

create or replace trigger dept_update_trigger10

before insert or update or delete

on dept

for each row

begin

if inserting then

insert into dept_log(logid,type,logdate,deptno,dname,loc)

values(dept_log_seq.nextval,'insert',sysdate,:new.deptno,:new.dname,:new.loc);

elsif updating then

insert into dept_log(logid,type,logdate,deptno,dname,loc)

values(dept_log_seq.nextval,'update',sysdate,:new.deptno,:new.dname,:new.loc);

else

insert into dept_log(logid,type,logdate,deptno,dname,loc)

values(dept_log_seq.nextval,'delete',sysdate,:old.deptno,:old.dname,:old.loc);

end if;

end;

/

DDL操作日志记录表创建脚本

drop table object_log purge;

drop sequence object_log_seq;

create sequence object_log_seq;

create table object_log(

oid number constraint pk_okd primary key,

username varchar2(50) not null,

operatedate date not null,

objecttype varchar2(50) not null,

objectowner varchar2(50) not null);

编写触发器实现对数据库对象操作的日志记录

create or replace trigger object_trigger

after create or drop or alter

on database

declare

begin

insert into scott.object_log VALUES

(scott.object_log_seq.nextval,ora_login_user,sysdate,ora_dict_obj_type,ora_dict_obj_owner);

end;

/

上一篇:深入理解nodejs中的异步编程


下一篇:nodejs 学习三 异步和同步