查看Oracle redo日志来分析SQL执行记录

1)设置Oracle数据字典导出路径参数(可选)

shutdown immediate
alter system set UTL_FILE_DIR='/opt/oracle/utl' scope=spfile;
execute dbms_logmnr_d.build(dictionary_filename => 'logminer_dict.ora', dictionary_location => '/opt/oracle/utl');
startup

 

2)增加需要分析的重做日志文件(在线归档均可)

execute dbms_logmnr.add_logfile(LogFileName=>'/opt/oracle/OraBase/oradata/inomc/redo01.log', options=>dbms_logmnr.new);
execute dbms_logmnr.add_logfile(LogFileName=>'/opt/oracle/OraBase/oradata/inomc/redo02.log', options=>dbms_logmnr.new);
execute dbms_logmnr.add_logfile(LogFileName=>'/opt/oracle/OraBase/oradata/inomc/redo03.log', options=>dbms_logmnr.new);

3)执行日志加载

使用数据字典

execute dbms_logmnr.start_logmnr(DictFileName=> '/opt/oracle/utl/logminer_dict.ora') ;

使用在线字典

execute dbms_logmnr.start_logmnr(Options=>dbms_logmnr.DICT_FROM_ONLINE_CATALOG) ;

4)查看日志

SELECT sql_redo FROM v$logmnr_contents;

5)结束分析,卸载日志
execute dbms_logmnr.end_logmnr;

你可能感兴趣的:(oracle)