實驗2:利用BBED工具刪除行資料

wangmj_183發表於2014-08-23

該實驗透過BBED工具刪除行資料,把2c改成3c標誌行資料刪除了,但是還需要空間的計算。

SQL> select * from perry ;

        ID NAME
---------- ----------
      1111 aaaa        --下面將演示刪除該行資料
      2222 bbbb
      3333 cccc

SQL> select dbms_rowid.rowid_object(rowid) object_id,
  2     dbms_rowid.rowid_relative_fno(rowid) file_id,

  3     dbms_rowid.rowid_block_number(rowid) block_id,

  4     dbms_rowid.rowid_row_number(rowid) num

  5     from perry ;

 OBJECT_ID    FILE_ID   BLOCK_ID        NUM
---------- ---------- ---------- ----------
     52508          6         16          0
     52508          6         16          1
     52508          6         16          2


BBED> set dba 6,16
        DBA             0x01800010 (25165840 6,16)

BBED> p kdbr   --perry表的三條記錄
sb2 kdbr[0]                                 @118      8076
sb2 kdbr[1]                                 @120      8064
sb2 kdbr[2]                                 @122      8052

BBED> p rowdata
ub1 rowdata[0]                              @8152     0x2c
ub1 rowdata[1]                              @8153     0x00
ub1 rowdata[2]                              @8154     0x02
ub1 rowdata[3]                              @8155     0x03
ub1 rowdata[4]                              @8156     0xc2
ub1 rowdata[5]                              @8157     0x22
ub1 rowdata[6]                              @8158     0x22
ub1 rowdata[7]                              @8159     0x04
ub1 rowdata[8]                              @8160     0x63
ub1 rowdata[9]                              @8161     0x63
ub1 rowdata[10]                             @8162     0x63
ub1 rowdata[11]                             @8163     0x63
ub1 rowdata[12]                             @8164     0x2c
ub1 rowdata[13]                             @8165     0x02
ub1 rowdata[14]                             @8166     0x02
ub1 rowdata[15]                             @8167     0x03
ub1 rowdata[16]                             @8168     0xc2
ub1 rowdata[17]                             @8169     0x17
ub1 rowdata[18]                             @8170     0x17
ub1 rowdata[19]                             @8171     0x04
ub1 rowdata[20]                             @8172     0x62
ub1 rowdata[21]                             @8173     0x62
ub1 rowdata[22]                             @8174     0x62
ub1 rowdata[23]                             @8175     0x62
ub1 rowdata[24]                             @8176     0x2c --此處往下即是我們要刪除的ID=1111的資料行
ub1 rowdata[25]                             @8177     0x00 --ITL
ub1 rowdata[26]                             @8178     0x02 --欄位個數
ub1 rowdata[27]                             @8179     0x03 --欄位長度
ub1 rowdata[28]                             @8180     0xc2
ub1 rowdata[29]                             @8181     0x0c
ub1 rowdata[30]                             @8182     0x0c --8180至8182為ID欄位內容

SQL> select dump(1111,16) from dual;

DUMP(1111,16)
-------------------
Typ=2 Len=3: c2,c,c

ub1 rowdata[31]                             @8183     0x04
ub1 rowdata[32]                             @8184     0x61
ub1 rowdata[33]                             @8185     0x61
ub1 rowdata[34]                             @8186     0x61
ub1 rowdata[35]                             @8187     0x61

BBED> set offset 8176  
        OFFSET          8176

BBED> d
 File: /oradata/susdata/perry01.dbf (6)
 Block: 16               Offsets: 8176 to 8191           Dba:0x01800010
------------------------------------------------------------------------
 2c000203 c20c0c04 61616161 0106bcb7

 <32 bytes per line>

BBED> m /x 3c  --修改2C標誌為3C
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /oradata/susdata/perry01.dbf (6)
 Block: 16               Offsets: 8176 to 8191           Dba:0x01800010
------------------------------------------------------------------------
 3c000203 c20c0c04 61616161 0106bcb7

 <32 bytes per line>

BBED> sum apply
Check value for File 6, Block 16:
current = 0x9650, required = 0x9650

BBED> verify
DBVERIFY - Verification starting
FILE = /oradata/susdata/perry01.dbf
BLOCK = 16

Block Checking: DBA = 25165840, Block Type = KTB-managed data block
data header at 0x2a96dbd264
kdbchk: the amount of space used is not equal to block size

        used=50 fsc=0 avsp=8028 dtl=8088 --空間使用存在問題,kdbhtosp=dtl(8088)-used(50)+2=8040,即塊總空間-使用空間+兩個位元組的欄位屬性空間(我們刪除了第一行 ,其長度為12,欄位屬性佔用2位元組,是在kdbhtosp裡,所以加2。而剩下的10個位元組是實際資料,放到保留區裡,而不能放到kdbhtosp裡)。

Block 16 failed with check code 6110

DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing   (Data) : 1
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0

SQL> select to_char(8040,'xxxxxxxxx') from dual;

TO_CHAR(80
----------
      1f68

BBED> m /x 681f offset 112  --修改kdbhtosp
 File: /oradata/susdata/perry01.dbf (6)
 Block: 16               Offsets:  112 to  623           Dba:0x01800010
------------------------------------------------------------------------
 681f0000 03008c1f 801f741f 992dc000 992dc000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 02000000 00200000 00000000 34140000 00000000 9a2dc000 01000000 992dc000
 9a2dc000 00000000 00000000 00000000 00000000 00000000 01000000 00000000
 8fa30000 00000010 992dc000 08000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 <32 bytes per line>

BBED> sum apply
Check value for File 6, Block 16:
current = 0x9664, required = 0x9664

BBED> p kdbh       
struct kdbh, 14 bytes                       @100    
   ub1 kdbhflag                             @100      0x00 (NONE)
   b1 kdbhntab                              @101      1
   b2 kdbhnrow                              @102      3
   sb2 kdbhfrre                             @104     -1
   sb2 kdbhfsbo                             @106      24   --塊自由空間開始使用
   sb2 kdbhfseo                             @108      8052 --塊自由空間結束使用
   b2 kdbhavsp                              @110      8028
   b2 kdbhtosp                              @112      8040

BBED> p ktbbhitl[1]
struct ktbbhitl[1], 24 bytes                @68     
   struct ktbitxid, 8 bytes                 @68     
      ub2 kxidusn                           @68       0x0009
      ub2 kxidslt                           @70       0x000e
      ub4 kxidsqn                           @72       0x00000166
   struct ktbituba, 8 bytes                 @76     
      ub4 kubadba                           @76       0x00800108
      ub2 kubaseq                           @80       0x00f7
      ub1 kubarec                           @82       0x1b
   ub2 ktbitflg                             @84       0x0001 (NONE)
   union _ktbitun, 2 bytes                  @86     
      b2 _ktbitfsc                          @86       0 --此處應該是10
      ub2 _ktbitwrp                         @86       0x0000
   ub4 ktbitbas                             @88       0x00000000

BBED> m /x a offset 86  --修改_ktbitfsc保留區
 File: /oradata/susdata/perry01.dbf (6)
 Block: 16               Offsets:   86 to  597           Dba:0x01800010
------------------------------------------------------------------------
 0a000000 00000000 00000000 00000001 0300ffff 1800741f 5c1f681f 00000300
 8c1f801f 741f992d c000992d c0000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000200 00000020
 00000000 00003414 00000000 00009a2d c0000100 0000992d c0009a2d c0000000
 00000000 00000000 00000000 00000000 00000100 00000000 00008fa3 00000000
 0010992d c0000800 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 <32 bytes per line>

BBED> sum apply
Check value for File 6, Block 16:
current = 0x966e, required = 0x966e

BBED> verify 
DBVERIFY - Verification starting
FILE = /oradata/susdata/perry01.dbf
BLOCK = 16

DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0

至此,已經完成。

SQL> alter system flush buffer_cache; --寫出快取

系統已更改。

SQL> select * from perry ;

        ID NAME
---------- ----------
      2222 bbbb
      3333 cccc

結果表明,第一行資料已被刪除。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26008584/viewspace-1256604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章