恢复己删除数据
一、创建模拟环境
代码如下 | 复制代码 |
SQL> create table hr.xifenfei (id number,name varchar2(20)) tablespace xff; Table created. SQL> insert into hr.xifenfei values(1,’xifenfei’); 1 row created. SQL> insert into hr.xifenfei values(2,’xff’); 1 row created. SQL> commit; Commit complete. SQL> select * from hr.xifenfei; ID NAME SQL> select rowid, ROWID REL_FNO BLOCKNO ROWNO SQL> delete from hr.xifenfei where id=2; 1 row deleted. SQL> commit; Commit complete. SQL> select * from hr.xifenfei; ID NAME SQL> shutdown immediate; |
二、bbed恢复删除数据
代码如下 | 复制代码 |
[oracle@localhost ~]$ bbed parfile=/tmp/parfile.cnf Password: BBED: Release 2.0.0.0.0 – Limited Production on Mon Aug 22 01:52:52 2011 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. ************* !!! For Oracle Internal Use only !!! *************** BBED> show all BBED> set dba 2,530 BBED> find /c xff <32 bytes per line> BBED> dump /v <16 bytes per line> BBED> dump /v offset 8160 <16 bytes per line> BBED> dump /v offset 8164 <16 bytes per line> BBED> dump /v offset 8162 <16 bytes per line> BBED> dump /v offset 8163 <16 bytes per line> BBED> modify /x 2c <32 bytes per line> BBED> sum apply |
三、核对结果
代码如下 | 复制代码 |
SQL> startup ORACLE instance started. Total System Global Area 236000356 bytes ID NAME 说明: |
找回被删除数据
创建模拟表数据
代码如下 | 复制代码 |
SQL> create table t_xifenfei(id number,name varchar2(10)); Table created. SQL> insert into t_xifenfei values(1,'xifenfei'); 1 row created. SQL> insert into t_xifenfei values(2,'XIFENFEI'); 1 row created. SQL> commit; Commit complete. dump数据块 dump文件内容 |
删除表数据
代码如下 | 复制代码 |
SQL> delete from t_xifenfei; 2 rows deleted. SQL> commit; Commit complete. SQL> alter system flush BUFFER_CACHE; System altered. SQL> alter system dump datafile 4 block 175; System altered. dump文件内容 通过对比这两次的dump文件发现 |
关闭数据库
代码如下 | 复制代码 |
SQL> select * from chf.t_xifenfei; no rows selected SQL> select name from v$datafile where file#=4; NAME ------------------------------------------------ /tmp/user01.dbf SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. bbed修改数据 |
启动数据库验证
代码如下 | 复制代码 |
SQL> startup ORACLE instance started. Total System Global Area 535662592 bytes Fixed Size 1346140 bytes Variable Size 411043236 bytes Database Buffers 117440512 bytes Redo Buffers 5832704 bytes Database mounted. Database opened. SQL> select * from chf.t_xifenfei; ID NAME ---------- ---------- 1 xifenfei 2 XIFENFEI |