SQL> create table t as select object_id,owner from dba_objects where rownum < 1000;
表已创建。
SQL> alter table t add constraint t_id_pk primary key(object_id);
SQL> update t set owner='AA' where object_id=500;
已更新 1 行。
SQL> select xidusn,xidslot,xidsqn,ubablk,ubafil,ubarec,to_char(START_SCN,'9999999999999') from v$transaction;
XIDUSN XIDSLOT XIDSQN UBABLK UBAFIL UBAREC TO_CHAR(START_
---------- ---------- ---------- ---------- ---------- ---------- --------------
6 6 1942 3683 3 13 4119141
SQL> select name from v$rollname where usn=6;
NAME
------------------------------
_SYSSMU6_2897970769$
SESSION2:
SQL> select spid from v$process where addr=(select paddr from v$session where sid=(select sid from v$mystat where rownum < 2));
SPID
------------------------
8463
SQL> alter system flush BUFFER_CACHE;
系统已更改。
SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';
会话已更改。
SQL> select * from test.t where object_id=500;
OBJECT_ID OWNER
---------- ------------------------------
500 SYS
SQL> ALTER SESSION SET EVENTS '10046 trace name context off';
会话已更改。
=====================
PARSING IN CURSOR #3 len=42 dep=0 uid=91 oct=3 lid=91 tim=1406434400557799 hv=3232312308 ad='24f4f408' sqlid='gqqq2p30akazn'
select * from test.t where object_id=500
END OF STMT
PARSE #3:c=2000,e=2579,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=51703167,tim=1406434400537084
EXEC #3:c=0,e=117,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,plh=51703167,tim=1406434400558001
WAIT #3: nam='SQL*Net message to client' ela= 6 driver id=1650815232 #bytes=1 p3=0 obj#=383 tim=1406434400558190
WAIT #3: nam='Disk file operations I/O' ela= 82 FileOperation=2 fileno=10 filetype=2 obj#=76193 tim=1406434400558384
WAIT #3: nam='db file sequential read' ela= 15 file#=10 block#=14593 blocks=1 obj#=76193 tim=1406434400558446
WAIT #3: nam='db file sequential read' ela= 9 file#=10 block#=14594 blocks=1 obj#=76193 tim=1406434400558527
WAIT #3: nam='db file sequential read' ela= 7 file#=10 block#=257 blocks=1 obj#=76192 tim=1406434400558557
WAIT #3: nam='db file sequential read' ela= 62 file#=3 block#=208 blocks=1 obj#=0 tim=1406434400558686
WAIT #3: nam='db file sequential read' ela= 8 file#=3 block#=3683 blocks=1 obj#=0 tim=1406434400558743
FETCH #3:c=0,e=542,p=5,cr=5,cu=0,mis=0,r=1,dep=0,og=1,plh=51703167,tim=1406434400558783
STAT #3 id=1 cnt=1 pid=0 pos=1 obj=76192 op='TABLE ACCESS BY INDEX ROWID T (cr=5 pr=5 pw=0 time=0 us cost=1 size=30 card=1)'
STAT #3 id=2 cnt=1 pid=1 pos=1 obj=76193 op='INDEX UNIQUE SCAN T_ID_PK (cr=2 pr=2 pw=0 time=0 us cost=1 size=0 card=1)'
WAIT #3: nam='SQL*Net message from client' ela= 217 driver id=1650815232 #bytes=1 p3=0 obj#=0 tim=1406434400577021
FETCH #3:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=51703167,tim=1406434400577053
WAIT #3: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=0 tim=1406434400577069
*** 2014-07-27 12:13:26.343
WAIT #3: nam='SQL*Net message from client' ela= 5766213 driver id=1650815232 #bytes=1 p3=0 obj#=0 tim=1406434406343299
CLOSE #3:c=0,e=17,dep=0,type=0,tim=1406434406343380
=====================
PARSING IN CURSOR #4 len=56 dep=0 uid=91 oct=42 lid=91 tim=1406434406343642 hv=3621752648 ad='0' sqlid='5p1y8sgbxz3u8'
ALTER SESSION SET EVENTS '10046 trace name context off'
END OF STMT
PARSE #4:c=0,e=234,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=0,tim=1406434406343641
EXEC #4:c=0,e=243,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=0,tim=1406434406343915
WAIT #3: nam='db file sequential read' ela= 15 file#=10 block#=14593 blocks=1 obj#=76193 tim=1406434400558446
WAIT #3: nam='db file sequential read' ela= 9 file#=10 block#=14594 blocks=1 obj#=76193 tim=1406434400558527
WAIT #3: nam='db file sequential read' ela= 7 file#=10 block#=257 blocks=1 obj#=76192 tim=1406434400558557
WAIT #3: nam='db file sequential read' ela= 62 file#=3 block#=208 blocks=1 obj#=0 tim=1406434400558686
WAIT #3: nam='db file sequential read' ela= 8 file#=3 block#=3683 blocks=1 obj#=0 tim=1406434400558743
其中:
SQL> select object_name from dba_objects where object_id=76193;
OBJECT_NAME
--------------------------------------------------------------------------------
T_ID_PK
SQL> select object_name from dba_objects where object_id=76192;
OBJECT_NAME
--------------------------------------------------------------------------------
T
select segment_name,header_file,header_block from dba_segments where segment_name='_SYSSMU6_2897970769$'SQL>
2 ;
SEGMENT_NAME HEADER_FILE HEADER_BLOCK
-------------------- ----------- ------------
_SYSSMU6_2897970769$ 3 208
WAIT #3: nam='db file sequential read' ela= 62 file#=3 block#=208 blocks=1 obj#=0 tim=1406434400558686
_SYSSMU6_2897970769$的块头
WAIT #3: nam='db file sequential read' ela= 8 file#=3 block#=3683 blocks=1 obj#=0 tim=1406434400558743
SQL> select owner, segment_name, segment_type
from dba_extents
where file_id = 3
and 3683 between block_id
and block_id + blocks - 1 2 3 4 5 ;
OWNER SEGMENT_NAME SEGMENT_TYPE
------------------------------ -------------------- ------------------
SYS _SYSSMU6_2897970769$ TYPE2 UNDO
顺序是读索引块14593和14594 读表块257 读UNDO HEADER 208 读UNDO块3683
sreace 跟踪:
[oracle@june2 ~]$ cat 8463.txt
8463 read(13, " 352 6 21i:3763773773771 3 3^;a200 "..., 8208) = 234
8463 gettimeofday({1406435222, 138141}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 gettimeofday({1406435222, 138423}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 gettimeofday({1406435222, 138551}, NULL) = 0
8463 gettimeofday({1406435222, 138567}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 gettimeofday({1406435222, 138726}, NULL) = 0
8463 gettimeofday({1406435222, 138829}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 gettimeofday({1406435222, 138917}, NULL) = 0
8463 gettimeofday({1406435222, 138932}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 gettimeofday({1406435222, 138989}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 times({tms_utime=24, tms_stime=6, tms_cutime=0, tms_cstime=0}) = 448603871
8463 gettimeofday({1406435222, 139078}, NULL) = 0
8463 gettimeofday({1406435222, 139099}, NULL) = 0
8463 gettimeofday({1406435222, 139117}, NULL) = 0
8463 gettimeofday({1406435222, 139135}, NULL) = 0
8463 gettimeofday({1406435222, 139168}, NULL) = 0
8463 gettimeofday({1406435222, 139184}, NULL) = 0
8463 getrusage(RUSAGE_SELF, {ru_utime={0, 249962}, ru_stime={0, 65989}, ...}) = 0
8463 gettimeofday({1406435222, 139302}, NULL) = 0
8463 gettimeofday({1406435222, 139317}, NULL) = 0
8463 pread64(18, "6242 0192002L332>