[20190104]bbed手工插入数据.txt --//下午没事,测试看看bbed手动插入数据,要求在块中有空间能容纳修改信息. --//特殊修复bbed实现起来还是比较麻烦,如果特殊修复可以在一台好的数据库上建立相同的表结果(注意字符集,大小头问题), --//插入数据,然后想办法引入对应的数据块中. --//我的测试仅仅一台机器,也可以演示操作过程,不要在生产系统做这样的操作!! 1.环境: SCOTT@book> @ ver1 PORT_STRING VERSION BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production SCOTT@book> create table empy as select * from emp where rownum<=2; Table created. SCOTT@book> select rowid,empy.* from empy; ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- AAAWH0AAEAAAAILAAA 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20 AAAWH0AAEAAAAILAAB 7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30 SCOTT@book> @ rowid AAAWH0AAEAAAAILAAA OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT ---------- ---------- ---------- ---------- -------------------- -------------------- ---------------------------------------- 90612 4 523 0 0x100020B 4,523 alter system dump datafile 4 block 523 ; SCOTT@book> select rowid,emp.* from emp where empno=7839; ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- AAAVREAAEAAAACXAAI 7839 KING PRESIDENT 1981-11-17 00:00:00 5000 10 SCOTT@book> @ rowid AAAVREAAEAAAACXAAI OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT ---------- ---------- ---------- ---------- -------------------- -------------------- ---------------------------------------- 87108 4 151 8 0x1000097 4,151 alter system dump datafile 4 block 151 ; --//测试想办法将dba=4,151的EMPNO=7839的记录插入dba=4,523的数据块中. SCOTT@book> alter system checkpoint; System altered. 2.首先确定导出记录长度以及偏移量: BBED> x /rnccntnnn dba 4,151 *kdbr[8] rowdata[197] @7818 ------------ flag@7818: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@7819: 0x01 cols@7820: 8 col 0[3] @7821: 7839 col 1[4] @7825: KING col 2[9] @7830: PRESIDENT col 3[0] @7840: *NULL* col 4[7] @7841: 1981-11-17 00:00:00 col 5[2] @7849: 5000 col 6[0] @7852: *NULL* col 7[2] @7853: 10 --//7853+3-1-7818+1 = 38,确定记录长度是38,从offset=7818开始. BBED> dump /v offset 7818 count 39 File: /mnt/ramdisk/book/users01.dbf (4) Block: 151 Offsets: 7818 to 7856 Dba:0x01000097 ----------------------------------------------------------------------------------------------------------- 2c010803 c24f2804 4b494e47 09505245 53494445 4e54ff07 77b50b11 01010102 l ,....O(.KING.PRESIDENT..w....... c233ff02 c10b2c l .3...., <32 bytes per line>) SCOTT@book> @ bbvi 4 151 BVI_COMMAND ---------------------------------------------------------------------------------------------------- bvi -b 1236992 -s 8192 /mnt/ramdisk/book/users01.dbf xxd -c16 -g 2 -s 1236992 -l 8192 /mnt/ramdisk/book/users01.dbf dd if=/mnt/ramdisk/book/users01.dbf bs=8192 skip=151 count=1 of=4_151.dd conv=notrunc 2>/dev/null od -j 1236992 -N 8192 -t x1 -v /mnt/ramdisk/book/users01.dbf hexdump -s 1236992 -n 8192 -C -v /mnt/ramdisk/book/users01.dbf alter system dump datafile '/mnt/ramdisk/book/users01.dbf' block 151; alter session set events 'immediate trace name set_tsn_p1 level 5'; alter session set events 'immediate trace name buffer level 16777367'; 9 rows selected. --//1236992+7818 =1244810,确定在文件的总偏移量1244810.可以执行命令如下: $ xxd -c39 -g 8 -s 1244810 -l 39 /mnt/ramdisk/book/users01.dbf 012fe8a: 2c010803c24f2804 4b494e4709505245 534944454e54ff07 77b50b1101010102 c233ff02c10b2c ,...翺(.KING.PRESIDENT.w?.....?.?, 3.确定导入的偏移量: BBED> p dba 4,523 kdbr sb2 kdbr[0] @142 8026 sb2 kdbr[1] @144 7983 --//查询最小的kdbr[N]值.这里对应kdbr[1]. BBED> x /rnccntnnn dba 4,523 *kdbr[1] rowdata[0] @8107 ---------- flag@8107: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@8108: 0x00 cols@8109: 8 col 0[3] @8110: 7499 col 1[5] @8114: ALLEN col 2[8] @8120: SALESMAN col 3[3] @8129: 7698 col 4[7] @8133: 1981-02-20 00:00:00 col 5[2] @8141: 1600 col 6[2] @8144: 300 col 7[2] @8147: 30 --//8107-38 = 8069,可以确定导入偏移量是8069. 4.生成bbed执行代码: $ xxd -c1 -g 1 -s 1244810 -l 38 /mnt/ramdisk/book/users01.dbf | cut -c10-11 | xargs -I{} echo assign /x offset @ = {} assign /x offset @ = 2c assign /x offset @ = 01 assign /x offset @ = 08 assign /x offset @ = 03 assign /x offset @ = c2 assign /x offset @ = 4f assign /x offset @ = 28 assign /x offset @ = 04 assign /x offset @ = 4b assign /x offset @ = 49 assign /x offset @ = 4e assign /x offset @ = 47 assign /x offset @ = 09 assign /x offset @ = 50 assign /x offset @ = 52 assign /x offset @ = 45 assign /x offset @ = 53 assign /x offset @ = 49 assign /x offset @ = 44 assign /x offset @ = 45 assign /x offset @ = 4e assign /x offset @ = 54 assign /x offset @ = ff assign /x offset @ = 07 assign /x offset @ = 77 assign /x offset @ = b5 assign /x offset @ = 0b assign /x offset @ = 11 assign /x offset @ = 01 assign /x offset @ = 01 assign /x offset @ = 01 assign /x offset @ = 02 assign /x offset @ = c2 assign /x offset @ = 33 assign /x offset @ = ff assign /x offset @ = 02 assign /x offset @ = c1 assign /x offset @ = 0b --//保存文件,利用vim的increment.vim插件执行如下:%Inc s8069 i1,生成如下代码,开头手工加入set dba 4,523. --//插件可以在如下链接下载:https://www.vim.org/scripts/script.php?script_id=842 set dba 4,523 assign /x offset 8069 = 2c assign /x offset 8070 = 01 assign /x offset 8071 = 08 assign /x offset 8072 = 03 assign /x offset 8073 = c2 assign /x offset 8074 = 4f assign /x offset 8075 = 28 assign /x offset 8076 = 04 assign /x offset 8077 = 4b assign /x offset 8078 = 49 assign /x offset 8079 = 4e assign /x offset 8080 = 47 assign /x offset 8081 = 09 assign /x offset 8082 = 50 assign /x offset 8083 = 52 assign /x offset 8084 = 45 assign /x offset 8085 = 53 assign /x offset 8086 = 49 assign /x offset 8087 = 44 assign /x offset 8088 = 45 assign /x offset 8089 = 4e assign /x offset 8090 = 54 assign /x offset 8091 = ff assign /x offset 8092 = 07 assign /x offset 8093 = 77 assign /x offset 8094 = b5 assign /x offset 8095 = 0b assign /x offset 8096 = 11 assign /x offset 8097 = 01 assign /x offset 8098 = 01 assign /x offset 8099 = 01 assign /x offset 8100 = 02 assign /x offset 8101 = c2 assign /x offset 8102 = 33 assign /x offset 8103 = ff assign /x offset 8104 = 02 assign /x offset 8105 = c1 assign /x offset 8106 = 0b --//执行如上代码后,检查: BBED> x /rnccntnnn dba 4,523 offset 8069 freespace[7923] @8069 --------------- flag@8069: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@8070: 0x01 cols@8071: 8 col 0[3] @8072: 7839 col 1[4] @8076: KING col 2[9] @8081: PRESIDENT col 3[0] @8091: *NULL* col 4[7] @8092: 1981-11-17 00:00:00 col 5[2] @8100: 5000 col 6[0] @8103: *NULL* col 7[2] @8104: 10 BBED> assign offset 8070=0x0; ub1 freespace[0] @8070 0x00 --//取消lock标识. --//OK正确.现在确定要插入的偏移量. BBED> p dba 4,523 kdbr sb2 kdbr[0] @142 8026 sb2 kdbr[1] @144 7983 --//注意修改kdbr行目录偏移是相对偏移要减去kbh的地址.当前块kdbh位于124. BBED> map dba 4,523 File: /mnt/ramdisk/book/users01.dbf (4) Block: 523 Dba:0x0100020b ------------------------------------------------------------ KTB Data Block (Table/Cluster) struct kcbh, 20 bytes @0 struct ktbbh, 96 bytes @20 struct kdbh, 14 bytes @124 struct kdbt[1], 4 bytes @138 sb2 kdbr[2] @142 ub1 freespace[7961] @146 ub1 rowdata[81] @8107 ub4 tailchk @8188 --//8069-124 = 7945. 插入1行到行目录中.首先增加记录数量. BBED> p kdbt struct kdbt[0], 4 bytes @138 sb2 kdbtoffs @138 0 sb2 kdbtnrow @140 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BBED> assign kdbt.kdbtnrow=3; sb2 kdbtnrow @140 3 BBED> p kdbh struct kdbh, 14 bytes @124 ub1 kdbhflag @124 0x00 (NONE) sb1 kdbhntab @125 1 sb2 kdbhnrow @126 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sb2 kdbhfrre @128 -1 sb2 kdbhfsbo @130 22 sb2 kdbhfseo @132 7983 sb2 kdbhavsp @134 7961 sb2 kdbhtosp @136 7961 BBED> assign kdbh.kdbhnrow=3 sb2 kdbhnrow @126 3 BBED> p dba 4,523 kdbr sb2 kdbr[0] @142 8026 sb2 kdbr[1] @144 7983 sb2 kdbr[2] @146 0 BBED> assign kdbr[2]=7945 sb2 kdbr[0] @146 7945 BBED> x /rnccntnnn dba 4,523 *kdbr[2] rowdata[0] @8069 ---------- flag@8069: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@8070: 0x00 cols@8071: 8 col 0[3] @8072: 7839 col 1[4] @8076: KING col 2[9] @8081: PRESIDENT col 3[0] @8091: *NULL* col 4[7] @8092: 1981-11-17 00:00:00 col 5[2] @8100: 5000 col 6[0] @8103: *NULL* col 7[2] @8104: 10 BBED> sum apply dba 4,523 Check value for File 4, Block 523: current = 0xaa11, required = 0xaa11 BBED> verify dba 4,523 DBVERIFY - Verification starting FILE = /mnt/ramdisk/book/users01.dbf BLOCK = 523 Block Checking: DBA = 16777739, Block Type = KTB-managed data block data header at 0x206be7c kdbchk: fsbo(22) wrong, (hsz 24) Block 523 failed with check code 6129 BBED> assign kdbh.kdbhfsbo=24; sb2 kdbhfsbo @130 24 BBED> sum apply dba 4,523 Check value for File 4, Block 523: current = 0xaa1f, required = 0xaa1f BBED> verify dba 4,523 DBVERIFY - Verification starting FILE = /mnt/ramdisk/book/users01.dbf BLOCK = 523 Block Checking: DBA = 16777739, Block Type = KTB-managed data block data header at 0x208de7c kdbchk: bad row offset slot 2 offs 7945 fseo 7983 dtl 8168 bhs 104 Block 523 failed with check code 6135 BBED> assign kdbh.kdbhfseo=7945; sb2 kdbhfseo @132 7945 BBED> sum apply dba 4,523 Check value for File 4, Block 523: current = 0xaa39, required = 0xaa39 BBED> verify dba 4,523 DBVERIFY - Verification starting FILE = /mnt/ramdisk/book/users01.dbf BLOCK = 523 Block Checking: DBA = 16777739, Block Type = KTB-managed data block data header at 0x208de7c kdbchk: the amount of space used is not equal to block size used=143 fsc=0 avsp=7961 dtl=8064 Block 523 failed with check code 6110 --//dtl-used-fsc = 8064-143-0 = 7921 BBED> assign kdbh.kdbhavsp=7921 sb2 kdbhavsp @134 7921 BBED> sum apply dba 4,523 Check value for File 4, Block 523: current = 0xabd1, required = 0xabd1 BBED> verify dba 4,523 DBVERIFY - Verification starting FILE = /mnt/ramdisk/book/users01.dbf BLOCK = 523 Block Checking: DBA = 16777739, Block Type = KTB-managed data block data header at 0x20b007c kdbchk: space available on commit is incorrect tosp=7961 fsc=0 stb=0 avsp=7921 Block 523 failed with check code 6111 BBED> assign kdbh.kdbhtosp=kdbh.kdbhavsp sb2 kdbhtosp @136 7921 BBED> sum apply dba 4,523 Check value for File 4, Block 523: current = 0xaa39, required = 0xaa39 BBED> verify dba 4,523 DBVERIFY - Verification starting FILE = /mnt/ramdisk/book/users01.dbf BLOCK = 523 --//终于OK!! 4.验证是否插入成功: SCOTT@book> alter system flush buffer_cache; System altered. SCOTT@book> select rowid,empy.* from empy; ROWID EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- AAAWH0AAEAAAAILAAA 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20 AAAWH0AAEAAAAILAAB 7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30 AAAWH0AAEAAAAILAAC 7839 KING PRESIDENT 1981-11-17 00:00:00 5000 10 --//步骤太多了,很容易出错...^_^.
[20190104]bbed手工插入数据.txt
来源:这里教程网
时间:2026-03-03 12:50:10
作者:
编辑推荐:
- [20190104]bbed手工插入数据.txt03-03
- Word文档中 怎样 增加 名目 标记03-03
- rman中进行catalog start with 无法注册部分备份文件03-03
- Word中 输出立方米 标记的三种 办法03-03
- Warning: ORA-16824: multiple warnings, including fast-start failover-related war03-03
- sql 性能优化03-03
- 怎样阻止Word文档自动创立超链接03-03
- 一个latch: ges resource hash list和library cache: mutex X并发的问题分析案例03-03
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- rman中进行catalog start with 无法注册部分备份文件
rman中进行catalog start with 无法注册部分备份文件
26-03-03 - 一个latch: ges resource hash list和library cache: mutex X并发的问题分析案例
- 性能分析大全
性能分析大全
26-03-03 - Oracle 18.3 ORA-12012 ORA-20001
Oracle 18.3 ORA-12012 ORA-20001
26-03-03 - 通过v$wait_chains视图诊断数据库hang和Contention
- RAC中的并行查询 DOP(Degree of Parallelism)
RAC中的并行查询 DOP(Degree of Parallelism)
26-03-03 - (重要)关于性能的几个主要动态视图
(重要)关于性能的几个主要动态视图
26-03-03 - Oracle date 和 timestamp 区别
Oracle date 和 timestamp 区别
26-03-03 - 深入理解Oracle调试事件:10046事件详解
深入理解Oracle调试事件:10046事件详解
26-03-03 - clusterware启动顺序——OHASD
clusterware启动顺序——OHASD
26-03-03
