You are on page 1of 4

connect as sys

sqlplus / as sysdba

SQL> alter system set utl_file_dir='/u01/apps/logminer_dir' scope=spfile;

System altered.

shutdown immediate
startup
show parameter utl_file_dir

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
utl_file_dir string /u01/apps/logminer_dir

Normally oracle records the change vector in the redo log files i.e. just the information that is
required to reconstruct the operation at recovery time. If you want additional information in the redo
log then you need to enable supplemental logging prior to generating log files that will be analyzed
by LogMiner. Therefore, at the very least, we will enable minimal supplemental logging, as the
following SQL statement shows:

SQL> SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

SUPPLEME
--------
NO

/* Minimum supplemental logging is not enabled. */

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

SQL> SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

SUPPLEME
--------
YES

/* Minimum supplemental logging is now enabled. */

SQL> alter system switch logfile;

System altered.

SQL> select g.group# , g.status , m.member


from v$log g, v$logfile m
where g.group# = m.group#
and g.status = 'CURRENT';

GROUP# STATUS MEMBER


---------- -------- -------------------------------------------
2 CURRENT D:/Oracle/product/10.2.0/oradata/test/redo03.log

Notes:

If you want to get the details of past operation which has happend just few mins ago then add
current redologfile(if that user's current redolog file is same as present)
If you want to get the details of past operation which has happend today then add archive redo log
files with the path

SQL> begin
dbms_logmnr_d.build
(
dictionary_filename => 'dictionary.ora',
dictionary_location => '/u01/apps/logminer_dir',
options => dbms_logmnr_d.store_in_flat_file
);
end;
/

PL/SQL procedure successfully completed.

/*
This has recorded the dictionary information into the file
"/u01/apps/logminer_dir/dictionary.dic".
*/

Now lets make a few user data changes by logging in as user SCOTT.

SQL> conn scott/tiger


connected.
SQL> insert into test_logmnr values (1,'TEST1');

1 row created.

SQL> insert into test_logmnr values (2,'TEST2');

1 row created.

SQL> commit;

Commit complete.

SQL> update test_logmnr set name = 'TEST';


2 rows updated.

SQL> commit;

After these changes lets log back in as sysdba and start LogMiner session.

SQL> conn / as sysdba


connected.
SQL> select g.group# , g.status , m.member
from v$log g, v$logfile m
where g.group# = m.group#
and g.status = 'CURRENT';

GROUP# STATUS MEMBER


---------- -------- -------------------------------------------
2 CURRENT D:/Oracle/product/10.2.0/oradata/test/redo03.log

/*
Log group 3 is still current, that means all of the changes we made are in this redo group.
*/

Note: If redo log file group has been changed then u get missing log file error, in that case add
archivelog files.

Adding redolog file:

sql>begin
dbms_logmnr.add_logfile
(
logfilename => 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO03.LOG',
options => dbms_logmnr.new
);
end;

Adding archive log files:

SQL>BEGIN
DBMS_LOGMNR.add_logfile (
options => DBMS_LOGMNR.new,
logfilename =>
'D:\oracle\product\10.2.0\flash_recovery_area\TEST\ARCHIVELOG\2013_02_19\O1_MF_1_69_8
L6W7683_.ARC');

DBMS_LOGMNR.add_logfile (
options => DBMS_LOGMNR.addfile,
logfilename =>
'D:\oracle\product\10.2.0\flash_recovery_area\TEST\ARCHIVELOG\2013_02_19\O1_MF_1_70_8
L6XB6K2_.ARC');
DBMS_LOGMNR.add_logfile (
options => DBMS_LOGMNR.addfile,
logfilename =>
'D:\oracle\product\10.2.0\flash_recovery_area\TEST\ARCHIVELOG\2013_02_19\O1_MF_1_71_8
L6YWDQ3_.ARC');
END;

sql>begin
dbms_logmnr.start_logmnr
(
dictfilename => 'D:\Jagdish\dictionary.ora',
options => dbms_logmnr.print_pretty_sql +
dbms_logmnr.no_sql_delimiter +
dbms_logmnr.ddl_dict_tracking
);
end;

set lines 1000


set pages 500
column scn format a6
column username format a8
column seg_name format a11
column sql_redo format a33
column sql_undo format a33

sql>select username,session_info,timestamp,log_id,table_name,username,rollback,operation,scn ,
seg_name , sql_redo , sql_undo
from V$LOGMNR_CONTENTS
where username = 'JAGS'
AND (seg_owner is null OR seg_owner = 'JAGS')

http://www.oracle-base.com/articles/8i/logminer.php
http://neeraj-dba.blogspot.in/2011/07/logminer-utility-in-oracle-10g.html