实验思路:
先在数据库中对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
---------- ---------- --------------------------------------------------
查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/database/storage/
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