一.Memory Dumps
1).Global Area
ALTER SESSION SET EVENTS 'immediate trace name global_area level n';
1 包含PGA2 包含SGA4 包含UGA8 包含indrect memory
2).Library Cache
ALTER SESSION SET EVENTS 'immediate trace name library_cache level n';
1 library cache统计信息2 包含hash table histogram3 包含object handle4 包含object结构(Heap 0)
3).Row Cache
ALTER SESSION SET EVENTS 'immediate trace name row_cache level n';
1 row cache统计信息2 包含hash table histogram8 包含object结构
4).Buffers
ALTER SESSION SET EVENTS 'immediate trace name buffers level n';
1 buffer header2 level 1 + block header3 level 2 + block contents4 level 1 + hash chain5 level 2 + hash chain6 level 3 + hash chain8 level 4 + users/waiters9 level 5 + users/waiters10 level 6 + users/waiters
5).Buffer
ALTER SESSION SET EVENTS 'immediate trace name buffer level n';
n为某个指定block的rdba,该命令可以转储某个block在buffer中的所有版本。
6).Heap
ALTER SESSION SET EVENTS 'immediate trace name heapdump level level';
1 PGA摘要2 SGA摘要4 UGA摘要8 Current call(CGA)摘要16 User call(CGA)摘要32 Large call(LGA)摘要1025 PGA内容2050 SGA内容4100 UGA内容8200 Current call内容16400 User call内容32800 Large call内容
7).Sub Heap
Oracle 9.0.1版本之前
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level n';
若n为subheap的地址,转储的是subheap的摘要信息若n为subheap的地址+1,转储的则是subheap的内容
Oracle 9.2.0版本之后
ALTER SESSION SET EVENTS 'immediate trace name heapdump_addr level n, addr m';
其中m为subheap的地址
n为1转储subheap的摘要,n为2转储subheap的内容
8).Process State
ALTER SESSION SET EVENTS 'immediate trace name processstate level n';
9).System State
ALTER SESSION SET EVENTS 'immediate trace name systemstate level n';
10).Error State
ALTER SESSION SET EVENTS 'immediate trace name errorstack level n';
0 Error stack1 level 0 + function call stack2 level 1 + process state3 level 2 + context area
11).Hang Analysis
ALTER SESSION SET EVENTS 'immediate trace name hanganalyze level n';
12).Work Area
ALTER SESSION SET EVENTS 'immediate trace name workareatab_dump level n';
1 SGA信息2 Workarea Table摘要信息3 Workarea Table详细信息
13).Latches
ALTER SESSION SET EVENTS 'immediate trace name latches level n';
1 latch信息2 统计信息
14).Events
ALTER SESSION SET EVENTS 'immediate trace name events level n';
1 session2 process3 system
15).Locks
ALTER SESSION SET EVENTS 'immediate trace name locks level n';
16).Shared Server Process
ALTER SESSION SET EVENTS 'immediate trace name shared_server_state level n';
n取值为1~14
17).Background Messages
ALTER SESSION SET EVENTS 'immediate trace name bg_messages level n';
n为pid+1
二.File Dumps
1).Block
Oracle 7之前
ALTER SESSION SET EVENTS 'immediate trace name blockdump level n';
n为block的rdba
Oracle8以后
ALTER SYSTEM DUMP DATAFILE file# BLOCK block#;
ALTER SYSTEM DUMP DATAFILE file#BLOCK MIN minimum_block#BLOCK MAX maximum_block#;
2).Tree Dump
ALTER SESSION SET EVENTS 'immediate trace name treedump level n';
n为object_id
3).Undo Segment Header
ALTER SYSTEM DUMP UNDO_HEADER 'segment_name';
4).Undo for a Transaction
ALTER SYSTEM DUMP UNDO BLOCK 'segment_name' XID xidusn xidslot xidsqn;
5).File Header
ALTER SESSION SET EVENTS 'immediate trace name file_hdrs level n';
1 控制文件中的文件头信息2 level 1 + 文件头信息3 level 2 + 数据文件头信息10 level 3
6).Control file
ALTER SESSION SET EVENTS 'immediate trace name controlf level n';
1 文件头信息2 level 1 + 数据库信息 + 检查点信息3 level 2 + 可重用节信息10 level 3
10g以后通常使用level 8
7).Redo log Header
ALTER SESSION SET EVENTS 'immediate trace name redohdr level n';
1 控制文件中的redo log信息2 level 1 + 文件头信息3 level 2 + 日志文件头信息10 level 3
8).Redo log
ALTER SYSTEM DUMP LOGFILE 'FileName';
ALTER SYSTEM DUMP LOGFILE 'FileName'SCN MIN MinimumSCNSCN MAX MaximumSCNTIME MIN MinimumTimeTIME MAX MaximumTimeLAYER LayerOPCODE OpcodeDBA MIN FileNumber . BlockNumberDBA MAX FileNumber . BlockNumberRBA MIN LogFileSequenceNumber . BlockNumberRBA MAX LogFileSequenceNumber . BlockNumber;
其中time = (((((yyyy - 1988)) * 12 + mm - 1) * 31 + dd - 1) * 24 + hh) * 60 + mi)* 60 + ss;
9).Loghist
ALTER SESSION SET EVENTS 'immediate trace name loghist level n';
10)session event
alter session set events '10046 trace name context forever, level n';
Level 0 tracing被关闭.这相当于设置sql_trace=false。Level 1 跟踪sql语句,包括解析、执行、提取、提交和回滚等(SQL_TRACE=TRUE).这是默认级别.Level 4 SQL trace信息加绑定变量值(包括变量的详细信息)。Level 8 SQL trace信息加等待事件信息.Level 12 SQL trace 信息,等待事件信息和绑定变量值.
转自 http://blog.chinaunix.net/uid-77311-id-2045051.html