1、介紹:                                                                                                 dbms_logmnr是Oracle在oracle8i所提供的新package。它主要用于分析log file文件(包括online redo log file,archived log file),將log file中的信息轉存到v$logmnr_contents中,從而獲取對oracle數(shù)據(jù)庫操作的歷史信息。它不僅可以分析oracle8i的log file,也可以分析oracle8的log file。信息主要包括在你分析的時間限制內數(shù)據(jù)庫數(shù)據(jù)作了些什么變更,執(zhí)行了哪些語句?! ?、使用方法 
  1)打開;init.ora文件,加入utl_file_dir=d:/oracle(注:改為自己的路徑,是logminer使用文件的默認路徑),然后應用新的設置打開oracle數(shù)據(jù)庫。 
  2)執(zhí)行SQL>;。 execute dbms_logmnr_d.build('shwdict.ora','D:/oracle'); ,(注:將生成d:/oracle/shwdict.ora文件,此文件可以以后重復使用,但不能同時用于幾個logmnr)用于生成數(shù)據(jù)字典;假如沒有dbms_logmnr_d包,需手工執(zhí)行@d:/oracle/ora8/rdbms/admin/dbmslmd.sql;假如執(zhí)行過程中報下標越界錯誤,則需要打開@d:/oracle/ora8/rdbms/admin/dbmslmd.sql文件,將其中的TYPE col_desc_array IS VARRAY(513) OF col_description的513加大,我是改成了1513,保存文件重新執(zhí)行@d:/oracle/ora8/rdbms/admin/dbmslmd.sql;(注:都要以sysdba身份登陸執(zhí)行)。 
  3)將要分析的日志文件加入要分析的log list中,察看有哪些日志文件可以用select * from v$logfile;查詢已經加入那些可以用select * from v$logmnr_logs(注:查詢必須在同一個會話中查詢,單獨開查詢將查不到)語句如下: 
 execute dbms_logmnr.add_logfile
('d:/oracle/oradata/shw/redo01_1.log',dbms_logmnr.new);execute dbms_logmnr.add_logfile
('d:/ORACLE/ORADATA/ORA/REDO02_1.LOG',dbms_logmnr.addfile);execute dbms_logmnr.add_logfile
('d:/ORACLE/ORADATA/ORA/REDO03_1.LOG',dbms_logmnr.addfile);  假如需要從分析列表里去掉一個文件用 
  ('d:/ORACLE/ORADATA/ORA/REDO03_1.LOG',dbms_logmnr.removefile); 
  4)更改會話時間表達方式(注一定要在本會話下修改,我開始發(fā)生錯誤就是因為在別的會話里修改的,假如答應,可以將數(shù)據(jù)庫默認的時間表達方式修改掉)會話內修改為alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; 系統(tǒng)設置在注冊表。 
  5)查詢分析的日志文件包含的scn范圍和日期范圍。 
 select low_time,high_time,low_scn,
next_scn from v$logmnr_logs;    會列出你加入的日志文件的以上信息。
    6)執(zhí)行分析: 
dbms_logmnr.start_logmnr(dictfilename=>;
 'd:/oracle/shwdict.ora',startscn=>;
xxxxxx,endscn=>;xxxxx,starttime =>; 
to_date('20030501 12:15:00','yyyymmdd hh24:mi:ss'),
 endtime =>; 
to_date('20030501 15:40:30','yyyymmdd hh24:mi:ss'));
                             要注重scn范圍和日期格式,格式要與你修改的一樣。      7)查詢 
Select SCN,timestamp, session# session_num, sql_redoFrom V$LOGMNR_CONTENTSOrder by 1