Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use log miner to analyze oracle logs

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

When we lose or change the database data due to careless misoperation, we need to recover the database objects based on the point in time to find the data we need. This time point cannot be considered accurate. We can get the exact time point without operation by analyzing the oracle log.

Oracle db provides an analysis log package logmnr

The use of logminer tools

-Mining redo log to find out the DDL or DML operations done at a certain point in time (including: point in time, datablock scn, sql statements)

Experimental test

SQL > select name from vastly archived logicNAMEMY Murray Melody Melochor Universe oracleArch2 Placement 2'883536782.dbfSQL > 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/arch2/1_2_883536782.dbf/oracle/arch2/1_3_883536782.dbf/oracle/arch2/1_4_883536782.dbf

-- start log miner to add logs for analysis

SQL > execute dbms_logmnr.add_logfile (logfilename= >'/ oracle/arch2/1_2_883536782.dbf',options= > dbms_logmnr.new); PL/SQL procedure successfully completed.

-add logs that need to be analyzed

SQL > execute dbms_logmnr.add_logfile (logfilename= >'/ oracle/arch2/1_3_883536782.dbf',options= > dbms_logmnr.addfile), PL/SQL procedure successfully completed.SQL > execute dbms_logmnr.add_logfile (logfilename= >'/ oracle/arch2/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 the analysis results

SQL > alter session set nls_date_format='yyyy-mm-dd hh34: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-06-09 00VOV 00' 'yyyy-mm-dd hh34:mi:ss') and "SAL" =' 2450' and "COMM" IS NULL and "DEPTNO" = '10' and ROWID =' AAAVbSAAFAAAACXABi' SYS 1494545 2015-06-28 04:24:44delete from "SCOTT". "T1" where "EMPNO" = '7839' and "ENAME" = 'KING' and "JOB" =' PRESIDENT' and "MGR" IS NULL and "HIREDATE" = TO_DATE ('1981-11-17 00 IS NULL and 00V,' yyyy-mm-dd hh34:mi:ss') and "SAL" = '5000' and "COMM" IS NULL and "DEPTNO" = '10' and ROWID =' AAAVbSAAFAAAACXABj' SYS 1494545 2015-06-28 04:24:44delete from "SCOTT". "T1" where "EMPNO" = '7844' and "ENAME" =' TURNER' and "JOB" = 'SALESMAN' and "MGR" =' 7698' and "HIREDATE" = TO_DATE ('1981-09-08 00VG 00V,' yyyy-mm-dd hh34:mi:ss') and "SAL" ='1.

-- end log miner analysis

SQL > execute dbms_logmnr.end_logmnr;PL/SQL procedure successfully completed.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report