实验思路: 先在数据库中对byss.更新a表的一行,找出与此行对应的FILE# BLOCK# 然后DUMP这个FILELE# 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
updatete可以通过上述句子查询 a set b=0 where b=7;修改数据块:file#4,block#153
###################################################################
2.使用DUMP file#4,block#153数据块查看该块的相关信息——主要是修改时的SCN20: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
SCN从DUMP信息中发现修改时:scn: 0x0000.00197b75 ---详见以下TRACE文件的具体信息
将SCN转化为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,0x2879bd8] 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: [0xfff.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: [0x2879bd8,0x22bfad98] lru: [0x22bfacec,0x217e4b8]
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#SCN信息在153数据块中[oracle@bys3 ~]$
cat par.bbd
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/undotbs010.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的SCNSCN wrap 高16-2byte和scn base 低32-4byte
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
在数据库中使用DUMP的SCN值 file#4,block#从153数据块信息中获得的SCN是一致的。这里的SCN:0x0000.00197b75转换为十进制SCN,转换为时间详见上一步DUMP时的转换,未详细写明。