Sometimes, we should recover one or more rows data which is deleted carelessly by users, but it is not necessary to recover the whole db and the flashback does not recovery the data because it's timeout.

For this moment, we should mine the log file to find the redo or undo data to recover the loss data and  find who delete the data.
How to use the log miner?

After oracle 9i, oracle provides a tool to mine the log file, there is a package of oracle dbms for the logmnr named dbms_logmnr. 

Make sure the db is archive log mode

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +FAR/arch1
Oldest online log sequence 833
Next log sequence to archive 834
Current log sequence 834
SQL> Example of log miner analyze procedure:
SQL>
SQL> create table test(id number); Table created. SQL> insert into test values(1); 1 row created. SQL> / 1 row created. SQL> / 1 row created. SQL> commit; Commit complete. SQL> begin
2 for i in 1..100 loop
3 insert into test values(i);
4 commit;
5 end loop;
6 end;
7 / PL/SQL procedure successfully completed. Switch log file by user system SQL> alter system switch logfile; System altered. SQL> Engine the log miner. select name, thread#, sequence#, first_change#, next_change# from V$ARCHIVED_LOG;
NAME THREAD# SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
-------------------- ---------- ---------- ------------- ------------
1 831 4062556971 4064186822
2 634 4063922165 4064177226
2 635 4064177226 4064275220
2 636 4064275220 4064429426
1 832 4064186822 4066775319
+FAR/arch1/1_833_817 1 833 4066775319 4066914873
620325.dbf +FAR/arch1/1_834_817 1 834 4066914873 4071821640
620325.dbf NAME THREAD# SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
-------------------- ---------- ---------- ------------- ------------
+FAR/arch2/2_637_817 2 637 4064429426 4071821645
620325.dbf SQL> exec dbms_logmnr.add_logfile(logfilename=>'+FAR/arch1/1_834_817620325.dbf', options=>dbms_logmnr.new); PL/SQL procedure successfully completed. SQL> options: dbms_logmnr.new stand for the first log file to be analyzed. SQL> exec dbms_logmnr.start_logmnr(options => sys.dbms_logmnr.dict_from_online_catalog); PL/SQL procedure successfully completed. SQL> select scn, timestamp, seg_name, seg_owner, sql_redo, sql_undo from v$logmnr_contents where seg_name='TEST' and set_owner='RAY'; SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
4071818078 11-SEP-13 TEST RAY create table test(id number);
4071818819 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '1
1'); ' and ROWID = 'AAAY8eAAFAAABbNAAA'; 4071818840 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '1
1'); ' and ROWID = 'AAAY8eAAFAAABbNAAB'; 4071818851 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '1
1'); ' and ROWID = 'AAAY8eAAFAAABbNAAC'; 4071819125 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '1 SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
1'); ' and ROWID = 'AAAY8eAAFAAABbNAAD'; 4071819127 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '2
2'); ' and ROWID = 'AAAY8eAAFAAABbNAAE'; 4071819129 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '3
3'); ' and ROWID = 'AAAY8eAAFAAABbNAAF'; 4071819131 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '4
4'); ' and ROWID = 'AAAY8eAAFAAABbNAAG'; ............... SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ---------------------------------------- 4071819228 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
53'); 3' and ROWID = 'AAAY8eAAFAAABbNAA3'; 4071819231 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
54'); 4' and ROWID = 'AAAY8eAAFAAABbNAA4'; 4071819233 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
55'); 5' and ROWID = 'AAAY8eAAFAAABbNAA5'; 4071819235 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5 SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
56'); 6' and ROWID = 'AAAY8eAAFAAABbNAA6'; 4071819237 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
57'); 7' and ROWID = 'AAAY8eAAFAAABbNAA7'; 4071819239 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
58'); 8' and ROWID = 'AAAY8eAAFAAABbNAA8'; 4071819241 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '5
59'); 9' and ROWID = 'AAAY8eAAFAAABbNAA9'; SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
4071819243 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '6
60'); 0' and ROWID = 'AAAY8eAAFAAABbNAA+'; 4071819244 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '6
61'); 1' and ROWID = 'AAAY8eAAFAAABbNAA/'; 4071819247 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '6
62'); 2' and ROWID = 'AAAY8eAAFAAABbNABA'; 4071819249 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '6
63'); 3' and ROWID = 'AAAY8eAAFAAABbNABB'; ...........
SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
78'); 8' and ROWID = 'AAAY8eAAFAAABbNABQ'; 4071819285 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '7
79'); 9' and ROWID = 'AAAY8eAAFAAABbNABR'; 4071819288 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
80'); 0' and ROWID = 'AAAY8eAAFAAABbNABS'; 4071819290 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
81'); 1' and ROWID = 'AAAY8eAAFAAABbNABT'; SCN TIMESTAMP SEG_NAME SEG_OWNER SQL_REDO SQL_UNDO
---------- --------- ---------- ---------- ---------------------------------------- ----------------------------------------
4071819292 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
82'); 2' and ROWID = 'AAAY8eAAFAAABbNABU'; 4071819294 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
83'); 3' and ROWID = 'AAAY8eAAFAAABbNABV'; 4071819296 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
84'); 4' and ROWID = 'AAAY8eAAFAAABbNABW'; 4071819298 11-SEP-13 TEST RAY insert into "RAY"."TEST"("ID") values (' delete from "RAY"."TEST" where "ID" = '8
85'); 5' and ROWID = 'AAAY8eAAFAAABbNABX'; SQL> exec dbms_logmnr.end_logmnr; PL/SQL procedure successfully completed.

For oracle log miner, we should pay attention to another main points.

A shallow summary of oracle log miner的更多相关文章

  1. oracle之二日志挖掘log miner

    日志挖掘 log miner 6.1 log miner的作用: 数据库恢复中有时会需要对Redo log进行分析, 要会使用log miner,以便确定要恢复的时间点或SCN 6.2 有两种日志挖掘 ...

  2. Oracle Log Block Size

    Although the size of redo entries is measured in bytes, LGWR writes the redo to the log files on dis ...

  3. ORACLE LOG的管理

    CREATE OR REPLACE PACKAGE PLOG IS /** * package name : PLOG *<br/> *<br/> *See : <a h ...

  4. oracle关闭监听log.xml文件生成步骤

    1.查看sqlnet.ora文件是否存在 cd $ORACLE_HOME/network/admin ls 如果不存在,copy一个过来 cp samples/sqlnet.ora . 2.修改sql ...

  5. Oracle【IT实验室】数据库备份与恢复之四:RMAN(备份与恢复管理器)

    RMAN是ORACLE提供的一个备份与恢复的工具,可以用来备份和还原数据库文件. 归档日志和控制文件.它也可以用来执行完全或不完全的数据库恢复. RMAN可以由命令行接口或者 OEM的 Backup ...

  6. oracle已知会导致错误结果的bug列表(Bug Issues Known to cause Wrong Results)

    LAST UPDATE:     1 Dec 15, 2016 APPLIES TO:     1 2 3 4 Oracle Database - Enterprise Edition - Versi ...

  7. oracle共享与专用模式的动态转换及区别(转载)

    一直没对专用于共享的互换搞清楚,找到了这篇文章 http://blog.csdn.net/tianlesoftware/archive/2010/06/26/5695784.aspx ,让我实践了一把 ...

  8. Oracle备份之RMAN

    1.备份:物理备份时文件层次的备份,逻辑备份时数据层次的备份,物理备份为主,逻辑备份作为补充.物理备份分为用户管理备份和RMAN备份,前者使用SQL命令和OS的cp命令进行文件备份,后者使用RMAN工 ...

  9. oracle rac理解和用途扩展

    Oracle RAC的优势在于利用多个节点(数据库实例)组成一个数据库,这样在保证了数据库高可用性的情况下更充分的利用了多个主机的性能,而且可以通过增加节点进行性能的扩展.实现Oracle RAC需要 ...

随机推荐

  1. 二代USBKEY与一代USBKEY有什么区别?使用时需要注意什么?

    二代USBKEY相较于一代USBKEY产品,增加了屏幕以及按键功能:可通过二代USBKEY产品的屏幕查看交易或操作信息,通过按键的方式进行上翻.下翻.确认.取消等操作. 二代USBKEY产品采用Mic ...

  2. 宣布正式发布 Windows Azure 多重身份验证

    身份和访问管理是安全之锚,是企业 IT 部门的首要任务.它是随时随地向员工.合作伙伴和客户提供访问的关键所在.今天,我们非常高兴地宣布正式发布 Windows Azure 多重身份验证,从而为 IT ...

  3. 在Livemedia的基础上开发自己的流媒体客户端

    一.背景 二.Livemedia框架介绍 1.总体框架 2.客户端框架 2.1 客户端openRTSP流程 2.2增加一种新的媒体 2.2.1增加媒体的format 2.2.2 新媒体需要考虑的问题 ...

  4. How to setup linked servers for SQL Server and Oracle 64 bit client

    感谢作者:Tim Ford. 图文并茂. 原帖地址: http://www.mssqltips.com/sqlservertip/1433/how-to-setup-linked-servers-fo ...

  5. Sql server 事务的两种用法

    事务(Transaction)是并发控制的单位,是用户定义的一个操作序列.这些操作要么都做,要么都不做,是一个不可分割的工作单位. 通过事务,SQL Server能将逻辑相关的一组操作绑定在一起,以便 ...

  6. 加特殊符号星号斜杠反斜杠/* \ */ !important等让css实现兼容各个浏览器的技巧的代码

       在编写css样式表的时候常常会碰到一写浏览器兼容的问题,象是不同内核的浏览器显示就不一定相同,不同版本的的浏览器也会产生上下兼容的问题,如何解决这些问题成了我们苦恼的问题,如果你对css hac ...

  7. js 字符串为空

    content.replace(/(^\s)|(\s$)/g, "")

  8. tasklet和工作队列

    tasklet机制和工作队列 http://blog.chinaunix.net/uid-28236237-id-3450753.html tasklet原理 http://www.kuqin.com ...

  9. Python之路:Python 基础(三)-文件操作

    操作文件时,一般需要经历如下步骤: 打开文件 操作文件 一.打开文件 文件句柄 = file('文件路径', '模式') # 还有一种方法open 例1.创建文件  f = file('myfile. ...

  10. gdb调试相关

    GDB调试及其调试脚本的使用返回脚本百事通一.GDB调试 1.1. GDB 概述 GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像VC.BCB等 ...