DBA通常建立error日志:
1.建立日志表:
create table errorlog
(
id number primary key,
errcode number,
errmsg varchar2(1024),
errdate date
);
2.建立序列
create sequence seq_errorlog_id start with 1 increment by 1;
3.PL_SQL中运用
declare
v_deptno dept.deptno%type := 10;
v_errcode number;
v_errmsg varchar2(1024);
begin
delete from dept where deptno = v_deptno;
commit;
exception
when others then
rollback;
v_errcode := SQLCODE;
v_errmsg := SQLERRM;
insert into errorlog values(seq_errorlog_id.nextval,v_errcode,v_errmsg,sysdate);
commit;
end;
--查看出错具体时间
select to_char(errdate,'YYYY-MM-DD HH24:MI:SS') from errorlog;