How to use log miner to analyze Oracle logs _oracle

Source: Internet
Author: User

When we do not care about the loss of database data, change, the database objects need to do based on point-in-time recovery, to find the data we need, this point can not be accurate to determine the timing of the Oracle log to be analyzed, and get the precise point of time without operation.
Oracle DB provides an analysis log pack LOGMNR
Use of Logminer Tools
-------Mining Redo log to find DDL or DML operations made at a point in time (including: Point-in-time, DataBlock SCN, SQL statement)
Experimental test

Sql> select name from V$archived_log;
 
NAME
--------------------------------------------------
/oracle/arch1/1_2_883536782.dbf
 
sql>
sql>
Sql> Delete from scott.t1; 
576 rows deleted. 
Sql> alter system archive log current; 
System altered. 
Sql> CREATE TABLE Scott.t6 as SELECT * from Scott.emp; 
Table created. 
Sql> alter system archive log current;
System altered.
Sql> select name from V$archived_log;
 
NAME
--------------------------------------------------
/oracle/arch1/1_2_883536782.dbf
/oracle /ARCH1/1_3_883536782.DBF
/oracle/arch1/1_4_883536782.dbf

--Start Log miner add logs to analyze

Sql> Execute dbms_logmnr.add_logfile (logfilename=> '/oracle/arch1/1_2_883536782.dbf ', Options=>dbms_ logmnr.new);

Pl/sql procedure successfully completed.

--Add logs to be analyzed

Sql> Execute dbms_logmnr.add_logfile (logfilename=> '/oracle/arch1/1_3_883536782.dbf ', Options=>dbms_ Logmnr.addfile); 

Pl/sql procedure successfully completed. 

Sql> Execute dbms_logmnr.add_logfile (logfilename=> '/oracle/arch1/1_4_883536782.dbf ', Options=>dbms_ logmnr.addfile) 

Pl/sql procedure successfully completed.

--Execute log Miner


Sql> Execute DBMS_LOGMNR.START_LOGMNR (options=>dbms_logmnr.dict_from_online_catalog); 

Pl/sql procedure successfully completed.

--Query analysis results

Sql> alter session set nls_date_format= ' Yyyy-mm-dd hh24:mi:ss ';
Session altered. 
Sql> Select Username,scn,timestamp,sql_redo from v$logmnr_contents where seg_name= ' T1 '; USERNAME SCN TIMESTAMP-----------------------------------------------------------Sql_redo----------------------- --------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------Delete from "SCOTT". " T1 "where" EMPNO = ' 7782 ' and ' ename ' = ' CLARK ' and ' JOB ' = ' MANAGER ' and ' MGR ' = ' 7839 ' and ' hiredate ' = to_date (' 1981-0 6-09 00:00:00 ', ' yyyy-mm-dd hh24:mi:ss ') and "SAL" = ' 245 0 ' and ' COMM ' is NULL and DEPTNO = ' ROWID '
 
Aaaacxabi '; SYS 1494545 2015-06-28 04:24:44 Delete from "SCOTT". " T1 "where" EMPNO = ' 7839 ' and ' ename ' = ' KING ' and ' JOB ' = ' PRESIDENT ' and ' MGR ' is NULL and ' hiredate ' = to_date (' 1981-1 1-17 00:00:00 ', ' yyyy-mm-dd hh24:mi:ss ') and "SAL" = ' 0 ' and ' COMM ' is NULL and "DEPTNO" = ' ten ' and ROWID = ' aaavbsaafaaaacxabj '; SYS 1494545 2015-06-28 04:24:44 Delete from "SCOTT". " T1 "where" EMPNO = ' 7844 ' and ' ename ' = ' TURNER ' and ' JOB ' = ' salesman ' and ' MGR ' = ' 7698 ' and ' hiredate ' = To_date (' 1981 -09-08 00:00:00 ', ' yyyy-mm-dd hh24:mi:ss ') and "SAL" = ' 1 ...

--End log miner analysis

Sql> execute DBMS_LOGMNR.END_LOGMNR;
 
Pl/sql procedure successfully completed.

The above is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.