Oracle8i Supplied Packages Reference Release 8.1.5 A68001-01 |
|
DBMS_LOGMNR
supplies the log analyzer tool with the list of filenames and SCNs required to initialize the tool. After this procedure completes, the server is ready to process SELECT
s against the V$LOGMNR_CONTENTS
view.
Redo log data is especially important for recovery, because you can use it to pinpoint when a database became corrupted.You can then use this information to recover the database to the state just prior to corruption.
After you have created a dictionary file with DBMS_LOGMNR_D
, you can begin analyzing archived redo logs.
DBMS_LOGMNR
.ADD_LOGFILE
procedure. You can view information about specified log files with V$LOGMNR_FILES
.
DBMS_LOGMNR
.START_LOGMNR
procedure. You can set the start and end SCN and time parameters in the START_LOGMNR
command to filter the redo records you will analyze. You can set the V$LOGMNR_PARAMETERS
view to view the parameters.
V$LOGMNR_CONTENTS
table. LogMiner returns all rows in SCN order, which is the same order applied in media recovery.
USER_COLMAP |
|
The V$LOGMNR_CONTENTS
table includes multiple sets of place holder columns. Each place holder column set contains a name column, a redo value column, and an undo value column. Each place holder column set can be assigned to a table and column via an optional LogMiner assignment file (logmnr
.opt
). After a place holder column is assigned, it can be used to select changes to the assigned column and table from the redo log stream.
For example, the assignment "colmap
=
SCOTT
EMP
(1
, EMPNO);
" assigns the PH1
place holder column set to the table and column; SCOTT
.EMP
, column EMPNO
. After being assigned, it is possible to select changes from the redo stream for the EMPNO
column of the EMP
table;
SELECT scn FROM V$LOGMNR_CONTENTS WHERE ph1_name=`EMPNO` AND ph1_redo=`12345`;
The redo stream is processed, and any changes setting the EMPNO
column of the EMP
table to the value 12345 are returned.
It is possible to have multiple assignments for each place holder column set. For example:
colmap = SCOTT EMP (1, EMPNO);
followed by
colmap = ACCOUNTING CUSTOMER (1, CUSTID);
In this case, the PH1
place holder column set has two assignments: to select only changes to the EMP
table, and to add the EMP
table name to the SELECT
;
SELECT scn FROM V$LOGMNR_CONTENTS WHERE seg_name = `EMP` AND ph1_name=`EMPNO` AND ph1_redo=`12345`;
or
SELECT scn FROM V$LOGMNR_CONTENTS WHERE seg_name = `CUSTOMER` AND ph1_name=`CUSTID` AND ph1_redo=`12345`;
The logmnr
.opt
file is processed when the DBMS_LOGMNR
.START_LOGMNR
procedure is performed and Options
is set to USE_COLMAP
(Options
= USE_COLMAP
). Setting USE_COLMAP
in Options
instructs the LogMiner to read and process the logmnr
.opt
file. The logmnr
.opt
file should be located in the same directory as the LogMiner dictionary file (UTL_FILE_DIR
).
After the place holder column assignment file (logmnr
.opt
) is processed, all subsequent selects from the V$LOGMNR_CONTENTS
table can use the assigned place holder columns. To change the assignments, update the logmnr
.opt
file, and re-start the LogMiner.
As the logmnr
.opt
file is processed the assigned columns are verified against the current LogMiner dictionary. If they do not exist, then the start fails.
line = 'colmap' <sp> '=' <sp> <schema> <sp> <table> <sp> '(' map ')' ';' map = <num> ',' <colname> [<num> ',' <colname>]
<sp> |
Space |
Words in quotes are fixed symbols:
|
Any number (limited to the number of place holder column sets) |
|
Name of the table |
|
Schema name |
|
Column name in the specified <schema>.<table> |
You can repeat <num
> ',' <colname
> inside the parentheses up to the number of place holder columns in V$LOGMNR_CONTENTS
table.
<table
>, <schema
> and <colname
> must be in all uppercase.
colmap = SCOTT EMP (1, EMPNO, 2 SAL, 3 JOB, 4 MGR, 5 COMM); colmap = SCOTT DEPT (1, DEPTNO);
ph1_redo
, ph1_undo
and ph4_redo
, ph4_undo
get filled:
colmap = SCOTT EMP (1, EMPNO, 2, EMPNO, 3, EMPNO, 4, MGR);
colmap
" and "=
":
colmap= SCOTT EMP (1, EMPNO, 2, SAL);
colmap = SCOTT EMP (1, EMPNO, 2);
colmap = SCOTT EMP (1, EMPNO)
colmap = scott EMP (1, EMPNO, 2 SAL);
colmap = SCOTT emp (1, EMPNO, 2 SAL);
colmap = SCOTT EMP (1, EMPNO, 2 SAL, 3 JOB, 4 MGR, 5 COMM, 6 ENAME);
REGION
is not part of the table:
colmap = SCOTT EMP (1, EMPNO, 2 SAL, 3 JOB, 4 REGION);
Subprogram | Description |
---|---|
Adds a file to the existing or newly created list of archive files to process. |
|
Initializes the log analyzer tool. |
|
Finishes a session. |
This procedure adds a file to the existing or newly created list of archive files to process.
In order to select information from the V$LOGMNR_CONTENTS
view, the LogMiner session must be set up with some information. This procedure tells the LogMiner session the list of logfiles to analyze.
DBMS_LOGMNR.ADD_LOGFILE( LogFileName IN VARCHAR2, Options IN BINARY_INTEGER default ADDFILE );
This procedure starts a LogMiner session.
DBMS_LOGMNR.START_LOGMNR( startScn IN NUMBER default 0, endScn IN NUMBER default 0, startTime IN DATE default '01-jan-1988', endTime IN DATE default '01-jan-2988', DictFileName IN VARCHAR2 default '', Options IN BINARY_INTEGER default 0 );
Parameter | Description |
---|---|
startScn |
Only consider redo records with |
endScn |
Only consider redo records with |
startTime |
Only consider redo records with timestamp greater than or equal to the |
endTime |
Only consider redo records with timestamp less than or equal to the |
DictFileName |
This flat file contains a snapshot of the database catalog. This must be specified if you expect to see reconstructed |
Options |
See "Constants for START_LOGMNR Options flag" and "Using the logmnr.opt Place Holder Column". |
The procedure fails with ORA-1280
for the following reasons:
LOW_SCN
, NEXT_SCN
) range containing the startScn
specified.
LOW_SCN
, NEXT_SCN
) range containing the endScn
specified.
LOW_TIME
, HIGH_TIME
) range containing the startTime
specified.
LOW_TIME
, HIGH_TIME
) range containing the endTime
specified.
DictFileName
does not exist.
DictFilename
.
DBMS_LOGMNR
.USE_COLMAP
is set without a logmnr
.opt
file.
DBMS_LOGMNR
.USE_COLMAP
is set and there are syntax errors in logmnr
.opt
file.
endScn
is less than startScn
.
endTime
is less than startTime
(and startScn
and endScn
were not specified).
This procedure finishes a session.
DBMS_LOGMNR.END_LOGMNR;
None.
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LogFileName => '/oracle/logs/log1.f', Options => dbms_logmnr.NEW); EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LogFileName => '/oracle/logs/log2.f', Options => dbms_logmnr.ADDFILE); EXECUTE DBMS_LOGMNR.START_LOGMNR( DictFileName =>'/oracle/dictionary.ora'); SELECT sql_redo FROM V$LOGMNR_CONTENTS;