Download as odp, pdf, or txt
Download as odp, pdf, or txt
You are on page 1of 12

Logminer

James Allen

Last updated: 9/01/2009


In this document substitute for the following:

UTLDIR -> Value of UTL_FILE_DIR


Find the value with:
SQL> show parameter UTL_FILE_DIR

ARCHPATH -> Path to the archive logs

Steps 1-3 only need to be performed once.


1. Installation

SQL> @$ORACLE_HOME/rdbms/admin/dbmslm.sql
2. Create Synonym

SQL> CREATE PUBLIC SYNONYM


DBMS_LOGMNR FOR SYS.DBMS_LOGMNR;
3. Supplemental Logging

Supplemental logging must be enabled at the


database level

SELECT SUPPLEMENTAL_LOG_DATA_MIN
FROM V$DATABASE;

If not turned on:


ALTER DATABASE ADD SUPPLEMENTAL LOG
DATA;
4. UTL_FILE_DIR

Check the database to find the value of


UTL_FILE_DIR
SQL> show parameters UTL_FILE_DIR
5. Build the dictionary

Build the dictionary to hold the redo data


SQL> execute
dbms_logmnr_d.build('dictionary.ora', 'UTLDIR');
6. Set the NLS_DATE_FORMAT parameter

SQL> ALTER SESSION SET


NLS_DATE_FORMAT = 'DD-MON-YYYY
HH24:MI:SS';
7. Add the arvhive logs to be mined

The first using DBMS_LOGMNR.NEW

SQL> EXECUTE DBMS_LOGMNR.ADD_LOGFILE(


LOGFILENAME => 'ARCHPATH/archive_log_name', OPTIONS =>
DBMS_LOGMNR.NEW);

To add multiple files, use DBMS_LOGMNR.ADDFILE

SQL> EXECUTE DBMS_LOGMNR.ADD_LOGFILE(


LOGFILENAME => 'ARCHPATH/archive_log_name', OPTIONS =>
DBMS_LOGMNR.ADDFILE);
8. Start Logminer

SQL> EXECUTE
DBMS_LOGMNR.START_LOGMNR(DICTFILENAME
=>'UTLDIR/dictionary.ora');
9. Find data by querying the
V$LOGMNR_CONTENTS table
Examples

SQL> select * from V$LOGMNR_CONTENTS where


table_name='table name';

SQL> select distinct RBASQN from V$LOGMNR_CONTENTS;


-- lists the arvhive logs

SQL> select distinct SEG_OWNER from


V$LOGMNR_CONTENTS;

SQL> select sql_redo from V$LOGMNR_CONTENTS where


table_name='table name';
-- lists just the queries that have been run against the table name
table.
10. To end a logminer session

Logout of the database or


SQL> exec DBMS_LOGMNR.END_LOGMNR

You might also like