06 使用bbed修复delete的数据--01
06 使用bbed修复delete的数据--01
根据rowid查看数据文件和block号
SYS@ orcl >select rowid,id,name,DBMS_ROWID.ROWID_RELATIVE_FNO(rowid) file#,DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid) block# from test.t1 where id=1; ROWID ID NAME FILE# BLOCK#
------------------ ---------- -------------------------------------------------- ---------- ----------
AAAVVFAAFAAAAiOAAA 1 AAAAA 5 2190
使用dump命令查看
SYS@ orcl >alter system dump datafile 5 block 2190;
System altered.
SYS@ orcl >select * from v$diag_info;
[root@DSI ~]# more /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_3081.trc
*** 2019-05-27 15:48:20.883
*** SESSION ID:(125.5) 2019-05-27 15:48:20.883
*** CLIENT ID:() 2019-05-27 15:48:20.883
*** SERVICE NAME:(SYS$USERS) 2019-05-27 15:48:20.883
*** MODULE NAME:(sqlplus@DSI (TNS V1-V3)) 2019-05-27 15:48:20.883
*** ACTION NAME:() 2019-05-27 15:48:20.883 kwqmnich: current time:: 7: 48: 20: 0
kwqmnich: instance no 0 repartition flag 1
kwqmnich: initialized job cache structure
Start dump data blocks tsn: 5 file#:5 minblk 2190 maxblk 2190 *** 2019-05-29 16:15:55.111
Block dump from cache:
Dump of buffer cache at level 4 for tsn=5 rdba=20973710
BH (0x7e7dcdc8) file#: 5 rdba: 0x0140088e (5/2190) class: 1 ba: 0x7e4b6000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 70,28
dbwrid: 0 obj: 87365 objn: 87365 tsn: 5 afn: 5 hint: f
hash: [0x8d5a4700,0x8d5a4700] lru: [0x7e7dcd80,0x7f7dcc48]
ckptq: [NULL] fileq: [NULL] objq: [0x7e7dcda8,0x885b38e0] objaq: [0x7e7dcdb8,0x885b38d0]
st: XCURRENT md: NULL fpin: 'kdswh01: kdstgr' tch: 4
flags: only_sequential_access
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: []
Block dump from disk:
buffer tsn: 5 rdba: 0x0140088e (5/2190)
scn: 0x0000.008dcadb seq: 0x02 flg: 0x06 tail: 0xcadb0602
frmt: 0x02 chkval: 0x5956 type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00007FC3EFE12200 to 0x00007FC3EFE14200
7FC3EFE12200 0000A206 0140088E 008DCADB 06020000 [......@.........]
7FC3EFE12210 00005956 00000001 00015545 008DCAC7 [VY......EU......]
7FC3EFE12220 00000000 00320002 01400888 000D0001 [......2...@.....]
7FC3EFE12230 000043A9 00C001B0 0029010D 00002001 [.C........).. ..]
7FC3EFE12240 008DCAC8 001B0004 000043A8 00C1973B [.........C..;...]
7FC3EFE12250 00340115 00002001 008DCADB 00000000 [..4.. ..........]
7FC3EFE12260 00000000 00020100 0016FFFF 1F5A1F70 [............p.Z.]
7FC3EFE12270 00001F5A 1F840002 00001F70 00000000 [Z.......p.......]
7FC3EFE12280 00000000 00000000 00000000 00000000 [................]
Repeat 500 times
7FC3EFE141D0 00000000 0203022C 620503C1 62626262 [....,......bbbbb]
7FC3EFE141E0 05777807 1B1C0F16 0203012C 410502C1 [.xw.....,......A]
7FC3EFE141F0 41414141 05777807 291B0F16 CADB0602 [AAAA.xw....)....]
Block header dump: 0x0140088e
Object id on Block? Y
seg/obj: 0x15545 csc: 0x00.8dcac7 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1400888 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00d.000043a9 0x00c001b0.010d.29 --U- 1 fsc 0x0000.008dcac8
0x02 0x0004.01b.000043a8 0x00c1973b.0115.34 --U- 1 fsc 0x0000.008dcadb
bdba: 0x0140088e
data_block_dump,data header at 0x7fc3efe12264
===============
tsiz: 0x1f98
hsiz: 0x16
pbl: 0x7fc3efe12264
76543210
flag=--------
ntab=1
nrow=2
frre=-1
fsbo=0x16
fseo=0x1f70
avsp=0x1f5a
tosp=0x1f5a
0xe:pti[] nrow=2 offs=0
0x12:pri[] offs=0x1f84
0x14:pri[] offs=0x1f70
block_row_dump:
tab 0, row 0, @0x1f84 ##具体的数据
tl: 20 fb: --H-FL-- lb: 0x1 cc: 3
col 0: [] c1 02
col 1: [] 41 41 41 41 41
col 2: [] 78 77 05 16 0f 1b 29
tab 0, row 1, @0x1f70
tl: 20 fb: --H-FL-- lb: 0x2 cc: 3
使用bbed进行查看
BBED> set file 5 block 2190
FILE# 5
BLOCK# 2190
BBED> map /v
BBED> p ktbbh
BBED> p kdbh
struct kdbh, 14 bytes @100
ub1 kdbhflag @100 0x00 (NONE)
sb1 kdbhntab @101 1
sb2 kdbhnrow @102 2
sb2 kdbhfrre @104 -1
sb2 kdbhfsbo @106 22
sb2 kdbhfseo @108 8048
sb2 kdbhavsp @110 8026
sb2 kdbhtosp @112 8026 BBED> p kdbr
sb2 kdbr[] @118 8068
sb2 kdbr[] @120 8048
BBED> p *kdbr[]
rowdata[]
-----------
ub1 rowdata[] @8168 0x2c
BBED> x/rnccccc ##对应行的值
rowdata[] @8168
-----------
flag@8168: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8169: 0x01
cols@8170: 3 col 0[] @8171: 1
col 1[] @8174: AAAAA
col 2[] @8180: xw....) SYS@ orcl >select dump(1,'') from dual; DUMP(1,'')
-----------------
Typ=2 Len=2: c1,2
SYS@ orcl >select dump('AAAAA','') from dual; DUMP('AAAAA','')
----------------------------
Typ=96 Len=5: 41,41,41,41,41
表记录
SYS@ orcl >select * from test.t1; ID NAME DATE1
---------- -------------------------------------------------- ---------
1 AAAAA 22-MAY-19
2 bbbbb 22-MAY-19
3 tt 23-MAY-19
Insert 一条记录,没提交事务,会写入DataBlock?
TEST@ orcl >create table t2 (id number ,name varchar2(20));
TEST@ orcl >insert into t2 values(1,'aaa');
TEST@ orcl >select rowid,id,name,DBMS_ROWID.ROWID_RELATIVE_FNO(rowid) file#,DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid) block# from test.t2; ROWID ID NAME FILE# BLOCK#
------------------ ---------- -------------------------------------------------- ---------- ----------
AAAVWKAAFAAAAiXAAA 1 aaa 5 2199 [oracle@DSI ~]$ sqlplus test/test
SQL> alter system flush buffer_cache; System altered. SQL> select rowid,id,name,DBMS_ROWID.ROWID_RELATIVE_FNO(rowid) file#,DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid) block# from test.t2; no rows selected
SQL> alter system dump datafile 5 block 2199; System altered. SQL> select * from v$diag_info;
dump查看
[oracle@DSI ~]$ more /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_13566.trc
7F08FBDDA9D0 027C5507 C1020004 02800113 C20302C1 [.U|.............]
7F08FBDDA9E0 00AC2005 04000402 71410000 000000DB [. ........Aq....]
7F08FBDDA9F0 012C7141 02C10202 61616103 72060603 [Aq,......aaa...r]
Block header dump: 0x01400897
Object id on Block? Y
seg/obj: 0x1558a csc: 0x00.917206 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1400890 ver: 0x01 opc: 0
inc: 0 exflg: 0 Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.00b.00007877 0x00c00389.016c.15 ---- 1 fsc 0x0000.00000000 ##对应的记录没有提交Flag=0
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000
bdba: 0x01400897
data_block_dump,data header at 0x7f08fbdd8a64
===============
tsiz: 0x1f98
hsiz: 0x14
pbl: 0x7f08fbdd8a64
76543210
flag=--------
ntab=1
nrow=1
frre=-1
fsbo=0x14
fseo=0x1f8e
avsp=0x1f7a
tosp=0x1f7a
0xe:pti[] nrow=1 offs=0
0x12:pri[] offs=0x1f8e
block_row_dump:
tab 0, row 0, @0x1f8e
tl: 10 fb: --H-FL-- lb: 0x1 cc: 2 ##0x1代表在那个事务槽
col 0: [] c1 02
col 1: [] 61 61 61
end_of_block_dump
End dump data blocks tsn: 5 file#: 5 minblk 2199 maxblk 2199
从dump上面看数据已经写入了block
bbed查看
BBED> set file 5 block 2199
BBED> p ktbbh
ub2 ktbitflg @60 0x0001 (NONE) ##01代表锁了1行记录,00表示没有提交
BBED> dump
File: /u01/app/oracle/oradata/orcl/test01.dbf (5)
Block: 2199 Offsets: 0 to 8191 Dba:0x01400897
------------------------------------------------------------------------
06a20000 97084001 06729100 00000304 0ed50000 01000000 8a550100 06729100
00000000 02003200 90084001 08000b00 77780000 8903c000 6c011500 01000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8e1f7a1f 7a1f0000 01008e1f e61b0500 06000700
..
05207c02 040002c1 13018002 c10303c2 024a7c02 040002c1 13018002 c10a03c2
07567c02 040002c1 13018002 c10503c2 07557c02 040002c1 13018002 c10303c2
05207c02 040002c1 13018002 c10203c2 024a7c02 040002c1 13018002 c10a03c2
07567c02 040002c1 13018002 c10403c2 07557c02 040002c1 13018002 c10203c2
0520ac00 02040004 00004171 db000000 41712c01 0202c102 03616161 03060672 ##尾部校验
BBED> dump /v offset 8000 count 200
File: /u01/app/oracle/oradata/orcl/test01.dbf (5)
Block: 2199 Offsets: 8000 to 8191 Dba:0x01400897 flg= 0x800 /*transaction is commited*/
0x2000 /* commit time is upper bound*/
0x1000 /* this trac is actice as of ktbbhcsc*/
使用BBED手工修复DELETE数据
TEST@ orcl >select * from t2; ID NAME
---------- --------------------------------------------------
1 aaa
2 bbbbb
3 ccccc
TEST@ orcl >alter system flush buffer_cache;
TEST@ orcl >select rowid,id,name,DBMS_ROWID.ROWID_RELATIVE_FNO(rowid) file#,DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid) block# from test.t2; ROWID ID NAME FILE# BLOCK#
------------------ ---------- -------------------------------------------------- ---------- ----------
AAAVWKAAFAAAAiXAAA 1 aaa 5 2199
AAAVWKAAFAAAAiXAAB 2 bbbbb 5 2199
AAAVWKAAFAAAAiXAAC 3 ccccc 5 2199
在bbed查看是否提交,也可以使用dump命令进行查看
BBED> set file 5 block 2199
FILE# 5
BLOCK# 2199
BBED> map /v
File: /u01/app/oracle/oradata/orcl/test01.dbf (5)
Block: 2199 Dba:0x01400897
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kdbh, 14 bytes @100
ub1 kdbhflag @100 BBED> p ktbbhitl
ub2 ktbitflg @60 0x2001 (KTBFUPB)
BBED> p kdbr
sb2 kdbr[] @118 8078
sb2 kdbr[] @120 8066
sb2 kdbr[] @122 8054 BBED> p *kdbr[]
rowdata[]
-----------
ub1 rowdata[] @8178 0x2c ##位置在相对位置加了100 ---8078+100(Assm),如果Mssm是加92
BBED> x/rncccccc
rowdata[] @8178
-----------
flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8179: 0x01
cols@8180: 2 ##2个列 col 0[] @8181: 1
col 1[] @8184: aaa
删除测试
TEST@ orcl >delete from t2 where id=3;
1 row deleted. TEST@ orcl >commit;
Commit complete. TEST@ orcl >alter system flush buffer_cache;
System altered. bbed重新登录一次
BBED> exit
BBED> p kdbr
sb2 kdbr[] @118 8078
sb2 kdbr[] @120 8066
sb2 kdbr[] @122 8054 BBED> p *kdbr[]
rowdata[]
----------
ub1 rowdata[] @8154 0x3c ##标记是3c,表示已经被删除 BBED> x/rncccccc
rowdata[] @8154 ##相对位置加100
----------
flag@8154: 0x3c (KDRHFL, KDRHFF, KDRHFD, KDRHFH)
lock@8155: 0x01
cols@8156: 0 TEST@ orcl >select * from t2;
ID NAME
---------- --------------------------------------------------
1 aaa
2 bbbbb
这里把3c修改成2c
BBED> modify /x 2c offset 8154 ##注意这里的位置是8154,而不是8054
File: /u01/app/oracle/oradata/orcl/test01.dbf (5)
Block: 2199 Offsets: 8154 to 8191 Dba:0x01400897
------------------------------------------------------------------------
2c010202 c1040563 63636363 2c000202 c1030562 62626262 2c000202 c1020361
61610106 6b77 <32 bytes per line> BBED> sum apply
Check value for File 5, Block 2199:
current = 0xf7f4, required = 0xf7f4
刷新一次,被删除的记录找到
TEST@ orcl >alter system flush buffer_cache;
System altered.
TEST@ orcl >select * from t2; ID NAME
---------- --------------------------------------------------
1 aaa
2 bbbbb
3 ccccc
下一篇介绍使用bbed进行update数据的测试和恢复
06 使用bbed修复delete的数据--01的更多相关文章
- 06 使用bbed提交delete的数据--01
使用bbed模拟delete提交操作 --session 1 TEST@ orcl )); Table created. TEST@ orcl ,'AAAAA'); row created. TEST ...
- 06 使用bbed修复update的数据--01
场景1 表t3 SQL> select * from t3; ID NAME ---------- -------------------- aaa bbbb SQL> update t3 ...
- 【Oracle】使用bbed恢复delete的数据
表中的数据被delete之后并不会真正删除数据,而是打了一个删除标记,仅仅要还没有被覆盖就能够恢复回来. 实验步骤例如以下: SYS@ORCL>create table bbed_test(x ...
- 使用bbed编辑研究oracle数据块结构
bbed是随oracle软件公布的一款数据块查看和编辑工具,作为一款内部工具.bbed的功能很强大,可是假设使用不当可能给数据库造成无法挽回的损失.因此.我们建议在使用bbed改动数据块前备份被改动的 ...
- 04 bbed修复system文件头损坏
04 bbed修复system文件头损坏 1 启动数据库,查看trace,在mount到open, SQL> startup mount; ORACLE instance started. To ...
- SQL中CRUD C——create 添加数据 R——read 读取数据 U——update 修改数据 D——delete 删除数据
在SQL server中对数据库的操作: 删除表:drop table 表名修改表:alter table 表名 添加列add 列名 列类型alter table 表名 drop column 列名 ...
- 什么?还在用delete删除数据《死磕MySQL系列 九》
系列文章 五.如何选择普通索引和唯一索引<死磕MySQL系列 五> 六.五分钟,让你明白MySQL是怎么选择索引<死磕MySQL系列 六> 七.字符串可以这样加索引,你知吗?& ...
- delete大批量数据引起空间爆满处理
前一天晚上做大表删除操作测试,分段删除,没删除100000条commit一次,由于存储过程打印了执行时间中途断网,无法看到执行时间于是直接kill了任务结果早上登录测试数据库发现空间爆满然后一时糊涂去 ...
- 从一个简单的Delete删数据场景谈TiDB数据库开发规范的重要性
故事背景 前段时间上线了一个从Oracle迁移到TiDB的项目,某一天应用端反馈有一个诡异的现象,就是有张小表做全表delete的时候执行比较慢,而且有越来越慢的迹象.这个表每次删除的数据不超过20行 ...
随机推荐
- mysql,oracle,sql server数据库默认的端口号,端口号可以为负数吗?以及常用协议所对应的缺省端口号
mysql,oracle,sql server数据库默认的端口号? mysql:3306 Oracle:1521 sql server:1433 端口号可以为负吗? 不可以,端口号都有范围的,0~65 ...
- 2019-10-31-VisualStudio-2019-新特性
title author date CreateTime categories VisualStudio 2019 新特性 lindexi 2019-10-31 08:48:27 +0800 2019 ...
- Linux服务器安装系统之1-LSI阵列卡Raid10配置方法
- PAT Advanced 1005 Spell It Right (20 分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- VB学习一
一.基础函数 CStr() 函数转化表达式为一个字符串 Trim() 移除字符串两侧的空白字符串或者其他预定义字符 成功:返回删除后的字符串 失败:返回空字符串 VBA.Mid(string,star ...
- 仿scikit-learn模式写的kNN算法
一.什么是kNN算法 k邻近是指每个样本都可以用它最接近的k个邻居来代表. 核心思想:如果一个样本在特征空间中的k个最相邻的样本中大多数属于一个某类别,则该样本也属于这个类别. 二.将kNN封装成kN ...
- strptime strftime时间函数总结
time(2) #include <time.h> time_t time(time_t *timep);//获取当前时间距离1970-01-01 00:00:00 经历的秒数 p = ...
- Django【第24篇】:JS实现的ajax和同源策略
JS实现的ajax和同源策略 一.回顾jQuery实现的ajax 首先说一下ajax的优缺点 优点: AJAX使用Javascript技术向服务器发送异步请求: AJAX无须刷新整个页面: 因为服务器 ...
- JConsole和VisualVM远程访问JMX
1.jvisualvm监控tomcat 修改tomcat的bin目录下的 catalina.sh文件,搜索JAVA_OPTS="",在引号中添加参数 JAVA_OPTS=" ...
- [CF852D] Exploration plan
问题描述 The competitors of Bubble Cup X gathered after the competition and discussed what is the best w ...