采用bbed修改scn的原理如下
File 1 block 1 是块头,记录了该 datafile header scn(整个datafile 的scn已该header scn为准的)
BBED> set file 1 block 1 FILE# 1 BLOCK# 1 BBED> p kcvfhckp (只用在block为1的地方) struct kcvfhckp, 36 bytes @484 struct kcvcpscn, 8 bytes @484 ub4 kscnbas @484 0x000f2d1a ub2 kscnwrp @488 0x0000 ub4 kcvcptim @492 0x2def0690 ub2 kcvcpthr @496 0x0001 union u, 12 bytes @500 struct kcvcprba, 12 bytes @500 ub4 kcrbaseq @500 0x00000005 ub4 kcrbabno @504 0x000033cf ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00
一个block 8k(8192),在偏移量为8的位置上记录了该block的SCN,
BBED> set block 128 BLOCK# 128 BBED> p bas_kcbh ub4 bas_kcbh @8 0x000f2d16
可以看到当前block的scn(0x000f2d16<0x000f2d1a) 正常
BBED> p tailchk ub4 tailchk @8188 0x2d160e01
Tailchecks (p tailchk)
The tail of an Oracle 8+ block is a concatenation of the lower order two bytes ofthe SCN base, the block type and the SCN sequence number.
Oracle block tail (该block的 最后4个bytes)由4个bytes组成,但实际上只用了低2个bytes来存放。 2个bytes的tail 由scn base,block type 和 scn sequence 组成。
E.g, if the SCN base number is 0x000f2d16 ,the block type is 0e and the SCN sequence number is 0x01, the tail check wouldbe 0x97280602:
SCN base Type SCN seq
2d16 0e 01
可以计算出 在block 的offset 8188(8192-2*2)为该block的 scn base=用p bas_kcbh查出的 后四位
所以在修改block的scn时,除了需要修改block bas_kcbh(offset 8) 还要修改tailchk的scn,只修改scn bash,而block type、scn sequence不变
并且注意:
在存放的时候是按照低位字节存放的the numbers are stored in little endian format (the low-order byte of thenumber is stored in memory at the lowest address) as this example database isrunning on Linux on an Intel platform.
根据以上描述同理,我们可以对数据库的scn进行变更,增大或者缩小。而2662的错误就是因为,某个数据块的scn与数据文件头scn不一致,比数据文件头的scn还要大导致的,所以同理也可以用此方法模拟ora-00600 2662错误。