oracle之logminer日志分析
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select sysdate from dual;
执行增删操作
alter system switch logfile; 切换当前的重做日志已以生成归档日志(相当于将之后的操作重新放到另一个日志中)
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; 修改格式方便查看
select sequence#,first_time from v$log_history order by first-time desc;
归档日志默认放在/u01/app/oracle/flash_recovery_area/ORCL/archivelog
查看分析日志
select t.FIRST_TIME,t.NAME from v$archived_log t order by t.FIRST_TIME desc;
使用logminer分析数据
conn /as sysdba
execute dbma_logmnr.add_logfile(logfilename=>'/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011-05_04/01_mf_1_12_6w0mmgmd_.arc',options=>dbms_logmnr.new);
启动logminer
execute dbms_logmnr.start_logmnr (options=>dbms_logmnr.dict_from_online_catalog);
把分析数据放入表中,并把表的权限授权给普通用户
create table logminer_20110504 tablespace BANK_TBS as select * from v$logmnr_contents;
grant select on logminer_20110504 to bankuser;
结束logminer分析
execute dbms_logmnr.end_logmnr;
查看分析日志结果
select t.timestamp,t.sql_redo,t.sql_undo from sys.logminer_20110504 t where t.seg_owner='BANKUSER' and t.sql_undo is not null;