使用DUMP資料塊與BBED檢視BLOCK對比資料庫修改時的SCN
實驗思路:
先在資料庫中對bys.a表的一行進行更新,查出此行對應的FILE# BLOCK#
然後DUMP此FILE# BLOCK#,檢視SCN資訊
使用BBED DUMP此FILE# BLOCK#,檢視SCN資訊
B
----------
55
7
3
19:55:15 BYS@ bys3>update a set b=0 where b=7;
1 row updated.
19:55:38 BYS@ bys3>commit;
Commit complete.
19:55:40 BYS@ bys3>select rowid,b from a; ---COMMIT的時間是19:55:40
ROWID B
------------------ ----------
AAAFOzAAEAAAACSAAA 55
AAAFOzAAEAAAACZAAA 0
AAAFOzAAEAAAACbAAA 3
19:57:15 BYS@ bys3>col object_name for a10
20:01:04 BYS@ bys3>select a.rowid,a.object_id,a.file_id,a.block_id,a.row_id,b.object_name,b from (select rowid,dbms_rowid.rowid_object(rowid) object_id,dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) block_id,dbms_rowid.rowid_row_number(rowid) row_id,b from bys.a) a,dba_objects b where a.object_id=b.object_id; ---如使用此語句,只需要修改標紅出的表名,欄位名即可。
ROWID OBJECT_ID FILE_ID BLOCK_ID ROW_ID OBJECT_NAM B
------------------ ---------- ---------- ---------- ---------- ---------- ----------
AAAFOzAAEAAAACbAAA 21427 4 155 0 A 3
AAAFOzAAEAAAACZAAA 21427 4 153 0 A 0
AAAFOzAAEAAAACSAAA 21427 4 146 0 A 55
通過上面的語句可以查詢出update a set b=0 where b=7;修改資料塊是:file#4,block#153
###################################################################
System altered.
檢視TRACE檔案位置方法有三個:
select value from v$diag_info where name like 'Default%';
SYS使用者執行:oradebug setmypid; oradebug tracefile_name
或者直接在user_dump_dest目錄中使用 ls -alt 找最近生成的檔案
20:05:32 BYS@ bys3>col name for a10
20:05:40 BYS@ bys3>col value for a50
20:05:49 BYS@ bys3>select * from v$diag_info where name like 'Default%';
INST_ID NAME VALUE
---------- ---------- --------------------------------------------------
1 Default Tr /u01/app/oracle/product/11.2.0/dbhome_1/log/diag/r
ace File dbms/bys3/bys3/trace/bys3_ora_17341.trc
從DUMP資訊中查出修改時SCN為:scn: 0x0000.00197b75 ---詳見下面的TRACE檔案具體資訊
轉換為SCN為:
20:19:17 BYS@ bys3>select to_number('197b75','xxxxxxxxx') from dual;
TO_NUMBER('197B75','XXXXXXXXX')
-------------------------------
1670005
20:19:38 BYS@ bys3>select scn_to_timestamp(1670005) from dual; --把SCN轉換為時間,驗證此SCN與UPDATE語句提交時的相符。
SCN_TO_TIMESTAMP(1670005)
---------------------------------------------------------------------------
29-NOV-13 07.55.39.000000000 PM
檢視bys3_ora_17341.trc中的詳細資訊如下:===擷取塊頭部分資訊:
Start dump data blocks tsn: 4 file#:4 minblk 153 maxblk 153
Block dump from cache:
Dump of buffer cache at level 4 for tsn=4 rdba=16777369
BH (0x22bfad14) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22b9e000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x22bfba7c,0x2879bdd8] lru: [0x22bfaea4,0x22bfac10]
ckptq: [NULL] fileq: [NULL] objq: [0x22bfaebc,0x25040784] objaq: [0x22bfbba8,0x22bfb9f0]
st: XCURRENT md: NULL fpin: 'kdswh01: kdstgr' tch: 6
flags: block_written_once redo_since_read
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [1]
BH (0x22bfb9f8) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22bbc000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x2879bdd8,0x22bfad98] lru: [0x22bfacec,0x217e4bb8]
lru-flags: hot_buffer
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: CR md: NULL fpin: 'kdswh01: kdstgr' tch: 0
cr: [scn: 0x0.197b72],[xid: 0x0.0.0],[uba: 0x0.0.0],[cls: 0x0.197b72],[sfl: 0x0],[lc: 0x0.14da6c]
flags: only_sequential_access
Block dump from disk:
buffer tsn: 4 rdba: 0x01000099 (4/153)
scn: 0x0000.00197b75 seq: 0x02 flg: 0x06 tail: 0x7b750602
frmt: 0x02 chkval: 0xe52c type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0xB6C41600 to 0xB6C43600
##########################################################3
blocksize=8192
listfile=bbedfile.txt
mode=edit
[oracle@bys3 ~]$ cat bbedfile.txt
1 /u01/oradata/bys3/system01.dbf 524288000
2 /u01/oradata/bys3/sysaux01.dbf 340787200
3 /u01/oradata/bys3/undotbs01.dbf 209715200
4 /u01/oradata/bys3/user01.dbf 52428800
[oracle@bys3 ~]$ bbed parfile=par.bbd
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Fri Nov 29 20:22:10 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set file 4 block 153
FILE# 4
BLOCK# 153
BBED> map
File: /u01/oradata/bys3/user01.dbf (4)
Block: 153 Dba:0x01000099
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
struct ktbbh, 72 bytes @20
struct kdbh, 14 bytes @100
struct kdbt[1], 4 bytes @114
sb2 kdbr[660] @118
ub1 freespace[719] @1438
ub1 rowdata[6031] @2157
ub4 tailchk @8188
BBED> print kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01000099
ub4 bas_kcbh @8 0x00197b75 ---從名字就比較好看出是scn wrap和scn base
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x02
ub1 flg_kcbh @15 0x06 (KCBHFDLC, KCBHFCKV)
ub2 chkval_kcbh @16 0xe52c
ub2 spare3_kcbh @18 0x0000
下面兩行對應的就是SCN的scn wrap 高16位-2byte和scn base 低32位-4byte 詳見:http://blog.csdn.net/q947817003/article/details/11590983
ub4 bas_kcbh @8 0x00197b75
ub2 wrp_kcbh @12 0x0000
scn計算方法:SCN=(SCN_WRP * 4294967296) + SCN_BAS
所以此資料塊上的SCN就是:0x0000.00197b75 --對應十進位制SCN:1670005 對應時間:29-NOV-13 07.55.39.000000000 PM
這個SCN的值與在資料庫中使用DUMP file#4,block#153資料塊資訊得出的SCN是一致的。此處的SCN:0x0000.00197b75轉換為十進位制SCN及轉換為時間詳見上一步DUMP時的轉換,不詳細寫出了。
先在資料庫中對bys.a表的一行進行更新,查出此行對應的FILE# BLOCK#
然後DUMP此FILE# BLOCK#,檢視SCN資訊
使用BBED DUMP此FILE# BLOCK#,檢視SCN資訊
1.在資料庫中對 bys.a表的一行進行更新,記錄此行的ROWID。
19:55:13 BYS@ bys3>select * from a;B
----------
55
7
3
19:55:15 BYS@ bys3>update a set b=0 where b=7;
1 row updated.
19:55:38 BYS@ bys3>commit;
Commit complete.
19:55:40 BYS@ bys3>select rowid,b from a; ---COMMIT的時間是19:55:40
ROWID B
------------------ ----------
AAAFOzAAEAAAACSAAA 55
AAAFOzAAEAAAACZAAA 0
AAAFOzAAEAAAACbAAA 3
19:57:15 BYS@ bys3>col object_name for a10
20:01:04 BYS@ bys3>select a.rowid,a.object_id,a.file_id,a.block_id,a.row_id,b.object_name,b from (select rowid,dbms_rowid.rowid_object(rowid) object_id,dbms_rowid.rowid_relative_fno(rowid) file_id,dbms_rowid.rowid_block_number(rowid) block_id,dbms_rowid.rowid_row_number(rowid) row_id,b from bys.a) a,dba_objects b where a.object_id=b.object_id; ---如使用此語句,只需要修改標紅出的表名,欄位名即可。
ROWID OBJECT_ID FILE_ID BLOCK_ID ROW_ID OBJECT_NAM B
------------------ ---------- ---------- ---------- ---------- ---------- ----------
AAAFOzAAEAAAACbAAA 21427 4 155 0 A 3
AAAFOzAAEAAAACZAAA 21427 4 153 0 A 0
AAAFOzAAEAAAACSAAA 21427 4 146 0 A 55
通過上面的語句可以查詢出update a set b=0 where b=7;修改資料塊是:file#4,block#153
###################################################################
2.使用DUMP file#4,block#153資料塊來檢視此塊相關資訊---主要是修改時的SCN
20:01:36 BYS@ bys3>alter system dump datafile 4 block 153;System altered.
檢視TRACE檔案位置方法有三個:
select value from v$diag_info where name like 'Default%';
SYS使用者執行:oradebug setmypid; oradebug tracefile_name
或者直接在user_dump_dest目錄中使用 ls -alt 找最近生成的檔案
20:05:32 BYS@ bys3>col name for a10
20:05:40 BYS@ bys3>col value for a50
20:05:49 BYS@ bys3>select * from v$diag_info where name like 'Default%';
INST_ID NAME VALUE
---------- ---------- --------------------------------------------------
1 Default Tr /u01/app/oracle/product/11.2.0/dbhome_1/log/diag/r
ace File dbms/bys3/bys3/trace/bys3_ora_17341.trc
從DUMP資訊中查出修改時SCN為:scn: 0x0000.00197b75 ---詳見下面的TRACE檔案具體資訊
轉換為SCN為:
20:19:17 BYS@ bys3>select to_number('197b75','xxxxxxxxx') from dual;
TO_NUMBER('197B75','XXXXXXXXX')
-------------------------------
1670005
20:19:38 BYS@ bys3>select scn_to_timestamp(1670005) from dual; --把SCN轉換為時間,驗證此SCN與UPDATE語句提交時的相符。
SCN_TO_TIMESTAMP(1670005)
---------------------------------------------------------------------------
29-NOV-13 07.55.39.000000000 PM
檢視bys3_ora_17341.trc中的詳細資訊如下:===擷取塊頭部分資訊:
Start dump data blocks tsn: 4 file#:4 minblk 153 maxblk 153
Block dump from cache:
Dump of buffer cache at level 4 for tsn=4 rdba=16777369
BH (0x22bfad14) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22b9e000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x22bfba7c,0x2879bdd8] lru: [0x22bfaea4,0x22bfac10]
ckptq: [NULL] fileq: [NULL] objq: [0x22bfaebc,0x25040784] objaq: [0x22bfbba8,0x22bfb9f0]
st: XCURRENT md: NULL fpin: 'kdswh01: kdstgr' tch: 6
flags: block_written_once redo_since_read
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [1]
BH (0x22bfb9f8) file#: 4 rdba: 0x01000099 (4/153) class: 1 ba: 0x22bbc000
set: 3 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,0
dbwrid: 0 obj: 21427 objn: 21427 tsn: 4 afn: 4 hint: f
hash: [0x2879bdd8,0x22bfad98] lru: [0x22bfacec,0x217e4bb8]
lru-flags: hot_buffer
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: CR md: NULL fpin: 'kdswh01: kdstgr' tch: 0
cr: [scn: 0x0.197b72],[xid: 0x0.0.0],[uba: 0x0.0.0],[cls: 0x0.197b72],[sfl: 0x0],[lc: 0x0.14da6c]
flags: only_sequential_access
Block dump from disk:
buffer tsn: 4 rdba: 0x01000099 (4/153)
scn: 0x0000.00197b75 seq: 0x02 flg: 0x06 tail: 0x7b750602
frmt: 0x02 chkval: 0xe52c type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0xB6C41600 to 0xB6C43600
##########################################################3
3.使用BBED 檢視file#4,block#153資料塊中的SCN資訊
[oracle@bys3 ~]$ cat par.bbdblocksize=8192
listfile=bbedfile.txt
mode=edit
[oracle@bys3 ~]$ cat bbedfile.txt
1 /u01/oradata/bys3/system01.dbf 524288000
2 /u01/oradata/bys3/sysaux01.dbf 340787200
3 /u01/oradata/bys3/undotbs01.dbf 209715200
4 /u01/oradata/bys3/user01.dbf 52428800
[oracle@bys3 ~]$ bbed parfile=par.bbd
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Fri Nov 29 20:22:10 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set file 4 block 153
FILE# 4
BLOCK# 153
BBED> map
File: /u01/oradata/bys3/user01.dbf (4)
Block: 153 Dba:0x01000099
------------------------------------------------------------
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
struct ktbbh, 72 bytes @20
struct kdbh, 14 bytes @100
struct kdbt[1], 4 bytes @114
sb2 kdbr[660] @118
ub1 freespace[719] @1438
ub1 rowdata[6031] @2157
ub4 tailchk @8188
BBED> print kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01000099
ub4 bas_kcbh @8 0x00197b75 ---從名字就比較好看出是scn wrap和scn base
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x02
ub1 flg_kcbh @15 0x06 (KCBHFDLC, KCBHFCKV)
ub2 chkval_kcbh @16 0xe52c
ub2 spare3_kcbh @18 0x0000
下面兩行對應的就是SCN的scn wrap 高16位-2byte和scn base 低32位-4byte 詳見:http://blog.csdn.net/q947817003/article/details/11590983
ub4 bas_kcbh @8 0x00197b75
ub2 wrp_kcbh @12 0x0000
scn計算方法:SCN=(SCN_WRP * 4294967296) + SCN_BAS
所以此資料塊上的SCN就是:0x0000.00197b75 --對應十進位制SCN:1670005 對應時間:29-NOV-13 07.55.39.000000000 PM
這個SCN的值與在資料庫中使用DUMP file#4,block#153資料塊資訊得出的SCN是一致的。此處的SCN:0x0000.00197b75轉換為十進位制SCN及轉換為時間詳見上一步DUMP時的轉換,不詳細寫出了。
相關文章
- 用bbed檢視資料檔案的資料塊block 0及block 1BloC
- 利用BBED修改資料塊SCN----極端環境下的資料恢復資料恢復
- oracle bbed修改資料塊的例子Oracle
- 持續更新,檢視dump oracle資料塊檢視Oracle
- Oracle 之利用BBED修改資料塊SCN----沒有備份資料檔案的資料恢復Oracle資料恢復
- 檢視當前Oracle資料庫的時間及其SCN號Oracle資料庫
- BBED 修改oracle 資料檔案的 SCN 號來做資料庫不完全恢復。Oracle資料庫
- 為什麼對資料塊修改的change的scn會小於對undo塊的修改?!
- 【BBED】使用bbed修改數字型別資料型別
- 【BBED】使用bbed修改字元型別資料字元型別
- 【kingsql分享】使用BBED修改Oracle資料檔案頭推進SCNSQLOracle
- 【BBED】使用bbed 修改日期型別的資料型別
- bbed_recover:恢復資料塊資料庫資料庫
- BBED (Oracle Block Brower and EDitor Tool) :資料塊修復工具OracleBloC
- 同一資料庫資料SCN號與時間的轉化資料庫
- dump資料塊
- --bbed_recover:恢復資料塊資料庫(mybbed)資料庫
- bbed_recover:恢復資料塊資料庫(續)資料庫
- 【檢視】SMON_SCN_TIME檢視--SCN與時間的對應關係
- 對資料庫檢視view的理解資料庫View
- MySQL資料庫檢視:檢視定義、建立檢視、修改檢視MySql資料庫
- 檢查資料塊損壞(Block Corruption)BloC
- ORACLE資料庫中SCN與時間的轉換Oracle資料庫
- dump表的資料塊
- 關聯式資料庫與文件資料庫對比資料庫
- 透過修改控制檔案scn推進資料庫scn資料庫
- 資料庫的查詢與檢視資料庫
- Oracle資料塊blockOracleBloC
- oracle block header_tail資料塊頭與資料塊尾OracleBloCHeaderAI
- 資料檔案的SCN和資料塊的SCN有何區別
- 【BBED】使用BBED修改資料檔案SCN,使該檔案從offline轉變為online
- [20150522]bbed與資料塊檢查和.txt
- bbed 之資料修改Ktbbh(Ktbbh資料)
- 資料庫壞塊Corrupt block的處理方法資料庫BloC
- oracle資料庫SCNOracle資料庫
- SCN與資料庫恢復的關係資料庫
- 使用events DUMP buffer cache中指定的資料塊
- 區塊鏈與分散式資料庫的比較區塊鏈分散式資料庫