sqlplus scott/oracle
create table t1 as select owner,object_id,object_name from dba_objects where rownum <100;
create index t1_idx1 on t1(object_id);
select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) blk# from t1;
FILE# BLK#
---------- ----------
7 371
7 371
7 371
7 371
7 371
7 371
..........................
7 371
99 rows selected.
select owner,object_id from dba_objects where object_name='T1_IDX1';
OWNER OBJECT_ID
-------------------- ----------
SCOTT 73254
oradebug setmypid
alter session set events 'immediate trace name treedump level 73254';
oradebug tracefile_name
--/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_64819.trc
----- begin tree dump
leaf: 0x1c0017b 29360507 (0: row:99.99 avs:6610)
----- end tree dump
select dbms_utility.data_block_address_file(to_number('1c0017b','xxxxxxxxxxx')) file_id,
dbms_utility.data_block_address_block(to_number('1c0017b','xxxxxxxxx')) block_id from dual;
FILE_ID BLOCK_ID
---------- ----------
7 379
--bbed 查看
BBED> set dba 7,379
DBA 0x01c0017b (29360507 7,379)
BBED> map /v
File: /oradata/ORCL/users01.dbf (7)
Block: 379 Dba:0x01c0017b
------------------------------------------------------------
KTB Data Block (Index Leaf)
struct kcbh, 20 bytes @0
ub1 type_kcbh @0
ub1 frmt_kcbh @1
ub2 wrp2_kcbh @2
ub4 rdba_kcbh @4
ub4 bas_kcbh @8
ub2 wrp_kcbh @12
ub1 seq_kcbh @14
ub1 flg_kcbh @15
ub2 chkval_kcbh @16
ub2 spare3_kcbh @18
struct ktbbh, 72 bytes @20
ub1 ktbbhtyp @20
union ktbbhsid, 4 bytes @24
struct ktbbhcsc, 8 bytes @28
sb2 ktbbhict @36
ub1 ktbbhflg @38
ub1 ktbbhfsl @39
ub4 ktbbhfnx @40
struct ktbbhitl[2], 48 bytes @44
struct kdxle, 32 bytes @100
struct kdxlexco, 16 bytes @100
sb2 kdxlespl @116
sb2 kdxlende @118
ub4 kdxlenxt @120
ub4 kdxleprv @124
ub1 kdxledsz @128
ub1 kdxleflg @129
sb2 kd_off[99] @132
ub1 freespace[6610] @330
ub1 rowdata[1188] @6940
ub4 tailchk @8188
BBED> p kdxle
struct kdxle, 32 bytes @100
struct kdxlexco, 16 bytes @100
ub1 kdxcolev @100 0x00
ub1 kdxcolok @101 0x00
ub1 kdxcoopc @102 0x80
ub1 kdxconco @103 0x02
ub4 kdxcosdc @104 0x00000000
sb2 kdxconro @108 99 --索引条数
sb2 kdxcofbo @110 234
sb2 kdxcofeo @112 6844
sb2 kdxcoavs @114 6610
sb2 kdxlespl @116 0
sb2 kdxlende @118 0
ub4 kdxlenxt @120 0x00000000
ub4 kdxleprv @124 0x00000000
ub1 kdxledsz @128 0x00
ub1 kdxleflg @129 0x00 (NONE)
BBED> d /v offset 108 count 5
File: /oradata/ORCL/users01.dbf (7)
Block: 379 Offsets: 108 to 112 Dba:0x01c0017b
-------------------------------------------------------
6300ea00 bc l c.... --99的十六进制是63
<16 bytes per line>
--修改成62,对应十进制是98
BBED> modify /x 62 offset 108
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
File: /oradata/ORCL/users01.dbf (7)
Block: 379 Offsets: 108 to 112 Dba:0x01c0017b
------------------------------------------------------------------------
6200ea00 bc
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 379:
current = 0xd38d, required = 0xd38d
BBED>
sqlplus scott/oracle
SQL> analyze table t1 validate structure cascade online;
analyze table t1 validate structure cascade online
*
ERROR at line 1:
ORA-01499: table/index cross reference failure - see trace file
--trc
row not found in index tsn: 4 rdba: 0x01c0017a
env [0x7ffe41ec9660]: (scn: 0x000000000025452f xid: 0x0003.00f.0000037c uba: 0x00000000.0000.00 statement num=0 parent xid: 0x0000.000.00000000 st-scn: 0x0000000000000000 hi-scn:
0x0000000000000000 ma-scn: 0x0000000000254504 flg: 0x00000060)
col 0; len 2; (2): c1 63
col 1; len 6; (6): 01 c0 01 73 00 60
Block header dump: 0x01c00173
Object id on Block? Y
seg/obj: 0x11e25 csc: 0x000000000023acd7 itc: 3 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00170 ver: 0x01 opc: 0
inc: 0 exflg: 0
--rman 逻辑检查结果:
----backup validate check logical DATAFILE 7;
**** kdxcofbo = 234 != 228, LvecSize: 0, hdrsize: 32, psasize: 0
---- end index block validation
2025-06-10 11:16:27.267*:KRB:krbb.c@13243:krbb1cf(): Error backing up file 7, block 379: logical corruption
--dbv 也能查逻辑坏块
[oracle@orcl:/home/oracle]$ dbv file=/oradata/ORCL/users01.dbf
DBVERIFY: Release 19.0.0.0.0 - Production on Tue Jun 10 15:36:26 2025
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /oradata/ORCL/users01.dbf
Block Checking: DBA = 29360507, Block Type = KTB-managed data block
**** kdxcofbo = 234 != 228, LvecSize: 0, hdrsize: 32, psasize: 0
---- end index block validation
Page 379 failed with check code 6401
DBVERIFY - Verification complete
Total Pages Examined : 640
Total Pages Processed (Data) : 68
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 16
Total Pages Failing (Index): 1
Total Pages Processed (Other): 479
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 77
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 2338021 (0.2338021)
----还原之前的变更:
modify /x 63 offset 108 dba 7,379
--------------下面模拟修改数据块
BBED> set dba 7,371
DBA 0x01c00173 (29360499 7,371)
BBED> p kdbh
struct kdbh, 14 bytes @124
ub1 kdbhflag @124 0x00 (NONE)
sb1 kdbhntab @125 1
sb2 kdbhnrow @126 99 --99行记录
sb2 kdbhfrre @128 -1
sb2 kdbhfsbo @130 216
sb2 kdbhfseo @132 6135
sb2 kdbhavsp @134 5919
sb2 kdbhtosp @136 5919
BBED> d /v offset 126 count 10
File: /oradata/ORCL/users01.dbf (7)
Block: 371 Offsets: 126 to 135 Dba:0x01c00173
-------------------------------------------------------
6300ffff d800f717 1f17 l c.........
<16 bytes per line>
BBED> modify /x 62 offset 126
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
File: /oradata/ORCL/users01.dbf (7)
Block: 371 Offsets: 126 to 135 Dba:0x01c00173
------------------------------------------------------------------------
6200ffff d800f717 1f17
<32 bytes per line>
BBED> sum apply
Check value for File 7, Block 371:
current = 0xdb12, required = 0xdb12
BBED>
BBED> p kdbt
struct kdbt[0], 4 bytes @138
sb2 kdbtoffs @138 0
sb2 kdbtnrow @140 99
BBED> modify /x 62 offset 140
--在线分析表
SQL> analyze table t1 validate structure cascade online;
analyze table t1 validate structure cascade online
*
ERROR at line 1:
ORA-01498: block check failure - see trace file
--rman 检测:
7 FAILED 0 77 641 2338021
File Name: /oradata/ORCL/users01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 1 68
Index 0 16
Other 0 479
validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_29905.trc for details
Finished backup at 10-JUN-25
SQL> select count(1) from t1;
COUNT(1)
----------
98
--原来是99行,现在变成了98行「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




