1.设置初始化参数UTL_FILE_DIR 以指定一个允许 PL/SQL 文件 I/O 的目录
utl_file_dir='D:\oracle\log';
2.执行 BMS_LOGMNR_D.BUILD 过程以创建字典文件
execute dbms_logmnr_d.build('ocp.ora','D:\oracle\log');
3.设置 V$LOGMNR_CONTENTS 视图:
SQL> execute dbms_logmnr.add_logfile('D:\ORACLE\PRODUCT\10.2.0\ORADATA\OCP\REDO01.LOG',dbms_logmnr.new);
SQL> execute dbms_logmnr.add_logfile('D:\ORACLE\PRODUCT\10.2.0\ORADATA\OCP\REDO02.LOG',dbms_logmnr.addfile);
一旦创建了字典文件您就可以开始分析重做日志第一步是使用
DBMS_LOGMNR.ADD_LOGFILE 过程指定要分析的日志文件
? DBMS_LOGMNR.NEW 创建一个新列表并指定第一个日志文件
? DBMS_LOGMNR.ADDFILE 向列表中添加其它日志文件
? DBMS_LOGMNR.REMOVEFILE 从列表中删除重做日志
EXECUTE DBMS_LOGMNR.START_LOGMNR(DICTFILENAME=>'D:\oracle\log\ocp.ora');
4.创建一个中间表用来存储对lv_insr_topay表的dml操作记录
(sql_redo varchar2(4000),
SELECT sql_redo,SQL_UNDO FROM v$logmnr_contents WHERE seg_name = 'LV_INSR_TOPAY';
SQL> select * from jy_logmnr ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
insert into "INSUR_CHANGDE"."LV_INSR_TOPAY"("PAY_INFO_NO","CALC_PRD","PAY_MONEY" delete from "INSUR_CHANGDE"."LV_INSR_TOPAY" where "PAY_INFO_NO" = '17524467' and
SELECT timestamp, username, sql_redo,SQL_UNDO
WHERE seg_name = 'LV_INSR_TOPAY';
SQL> SELECT timestamp, username, sql_redo,SQL_UNDO
3 WHERE seg_name = 'LV_INSR_TOPAY';
TIMESTAMP USERNAME SQL_REDO SQL_UNDO
----------- ------------------------------ -------------------------------------------------------------------------------- --------------------------------------------------------------------------------
2012-1-1 13 insert into "INSUR_CHANGDE"."LV_INSR_TOPAY"("PAY_INFO_NO","CALC_PRD","PAY_MONEY" delete from "INSUR_CHANGDE"."LV_INSR_TOPAY" where "PAY_INFO_NO" = '17524467' and
EXECUTE DBMS_LOGMNR.END_LOGMNR;