BANNER
----------------------------------------------------------------
Oracle Database 10gEnterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 – Production
SQL> show parameter undo;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
SQL> conn japie/japie
Connected.
SQL> create tabletest_delayed as select * from user_objects;
Table created.
SQL> select count(1) from test_delayed;
COUNT(1)
----------
3
SQL> update test_delayed set object_id=1 where object_name='TEST_REDO';
1 row updated.
SQL> update test_delayed set object_id=2 where object_name='TEST_DELAYED';
1 row updated.
SQL> -----不提交
查询回滚段信息:
SQL> col segment_name for a20;
select owner,segment_name,SEGMENT_ID,FILE_ID,BLOCK_ID,STATUS
SQL> tablespace_name from dba_rollback_segs;
2
OWNER SEGMENT_NAME SEGMENT_ID FILE_ID BLOCK_ID TABLESPACE_NAME
------ -------------------- ---------- ---------- ---------- ----------------
SYS SYSTEM 0 1 9 ONLINE
PUBLIC _SYSSMU1$ 1 2 9 ONLINE
PUBLIC _SYSSMU2$ 2 2 25 ONLINE
PUBLIC _SYSSMU3$ 3 2 41 ONLINE
PUBLIC _SYSSMU4$ 4 2 57 ONLINE
PUBLIC _SYSSMU5$ 5 2 73 ONLINE
PUBLIC _SYSSMU6$ 6 2 89 ONLINE
PUBLIC _SYSSMU7$ 7 2 105 ONLINE
PUBLIC _SYSSMU8$ 8 2 121 ONLINE
PUBLIC _SYSSMU9$ 9 2 137 ONLINE
PUBLIC _SYSSMU10$ 10 2 153 ONLINE
11 rows selected.
查询事务信息
SQL> select xidusn,xidslot,xidsqn,ubablk,ubafil,ubarec from v$transaction;
XIDUSN XIDSLOT XIDSQN UBABLK UBAFIL UBAREC
---------- ---------- ---------- ---------- - --------- ----------
6 40 427 99 2 7
查询该活动事务所在的回滚段
SQL> select * from v$rollname where usn = &usn;
Enter value for usn: 6
old 1: select * from v$rollname where usn = &usn
new 1: select * from v$rollname where usn = 6
USN NAME
---------- ------------------------------
6_SYSSMU6$
查询test_delayed对象所在的fileid 和blockid由于数据对象还存在buffer
SQL> select b.segment_name,a.file#,a.dbarfil,a.dbablk,a.class,
2 a.state,decode(bitand(flag,1), 0, 'N', 'Y') DIRTY
3 from x$bh a,dba_extents b
4 where b.RELATIVE_FNO = a.dbarfil
5 and b.BLOCK_ID <= a.dbablk and b.block_id + b.blocks > a.dbablk
6 and b.owner='GABRIEL' and b.segment_name='TEST_DELAYED';
SEGMENT_NAME FILE# DBARFIL DBABLK CLASS STATE D
-------------------- ---------- ---------- ---------- ---------- ---------- -
TEST_DELAYED 8 8 28 1 1 N
TEST_DELAYED 8 8 28 1 3 N
TEST_DELAYED 8 8 28 1 3 N
TEST_DELAYED 8 8 27 4 1 N
TEST_DELAYED 8 8 27 4 3 N
由上可知:x$bh.class= 4 表示为segment header x$bh.state =3为前镜像块,因此file#=8
Dbablk=28为数据块
*-----------------------------
* Rec #0x1 slt: 0x06 objn: 49948(0x0000c31c) objd: 49948 tblspc: 2(0x00000002)
* Layer: 11 (Row) opc: 1 rci 0x00
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00800062
*-----------------------------
KDO undo record:
KTB Redo
op: 0x02 ver: 0x01
op: C uba: 0x00800062.0156.1e
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x00c05be8 hdba: 0x00c05be3
itli: 2 ispac: 0 maxfr: 4858
tabn: 0 slot: 7(0x7) flag: 0x2c lock: 0 ckix: 0
ncol: 12 nnew: 2 size: 0
col 9: [ 1] 80
col 10: [ 1] 80
*-----------------------------
* Rec #0x2 slt: 0x06 objn: 49871(0x0000c2cf) objd: 49871 tblspc: 2(0x00000002)
* Layer: 10 (Index) opc: 22 rci 0x01
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
index undo for leaf key operations
KTB Redo
op: 0x04 ver: 0x01
op: L itl: xid: 0x0003.02a.000001b9 uba: 0x008000d7.0174.23
flg: C--- lkc: 0 scn: 0x0000.000f5659
Dump kdilk : itl=2, kdxlkflg=0xc1 sdc=0 indexid=0xc059ab block=0x00c059b0
*-----------------------------
* Rec #0x6 slt: 0x28 objn: 53018(0x0000cf1a) objd: 53018 tblspc: 9(0x00000009)
* Layer: 11 (Row) opc: 1 rci 0x00
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
uba: 0x00800063.0156.04 ctl max scn: 0x0000.000f5354 prv tx scn: 0x0000.000f535c
txn start scn: scn: 0x0000.000f59ac logon user: 64
prev brb: 8388871 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x03 ver: 0x01
op: Z
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0200001c hdba: 0x0200001b
itli: 2 ispac: 0 maxfr: 4858
tabn: 0 slot: 1(0x1) flag: 0x2c lock: 0 ckix: 183
ncol: 12 nnew: 1 size: 2
col 2: [ 4] c3 06 1d 2d
*-----------------------------
* Rec #0x7 slt: 0x28 objn: 53018(0x0000cf1a) objd: 53018 tblspc: 9(0x00000009)
* Layer: 11 (Row) opc: 1 rci 0x06
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
KDO undo record:
KTB Redo
op: 0x02 ver: 0x01
op: C uba: 0x00800063.0156.06
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0200001c hdba: 0x0200001b
itli: 2 ispac: 0 maxfr: 4858
tabn: 0 slot: 2(0x2) flag: 0x2c lock: 0 ckix: 0
ncol: 12 nnew: 1 size: 2
col 2: [ 4] c3 06 1f 13
由两次的dump对比可以得出:块延迟清除只是更改了undo segment header的事务信息状态,数据块与undo块信息均保持不变
--
SQL> set echo off
SQL> set autotrace on
SQL> select * from gabriel.test_delayed; ---将数据块再次缓存在cache buffer
Note
-----
- dynamic sampling used for this statement
Statistics
----------------------------------------------------------
178 recursive calls
0 db block gets
27 consistent gets
7 physical reads
72 redo size
1364 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
0 sorts (disk)
3 rows processed
再次转存数据块信息
SQL> alter system dump datafile 8 block 28;