Oracle Trace And Dump
Table of Contents

Oracle 常用dump命令

Reference: http://blog.csdn.net/tianlesoftware/article/details/4977909

一.Memory Dumps

1).Global Area

ALTER SESSION SET EVENTS ‘immediate trace name global_area level n’;
1 包含PGA
2 包含SGA
4 包含UGA
8 包含indrect memory

2).Library Cache

ALTER SESSION SET EVENTS ‘immediate trace name library_cache level n’;
1 library cache统计信息
2 包含hash table histogram
3 包含object handle
4 包含object结构(Heap 0)

3).Row Cache

ALTER SESSION SET EVENTS ‘immediate trace name row_cache level n’;
1 row cache统计信息
2 包含hash table histogram
8 包含object结构

4).Buffers

ALTER SESSION SET EVENTS ‘immediate trace name buffers level n’;
1 buffer header
2 level 1 + block header
3 level 2 + block contents
4 level 1 + hash chain
5 level 2 + hash chain
6 level 3 + hash chain
8 level 4 + users/waiters
9 level 5 + users/waiters
10 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 stack
1 level 0 + function call stack
2 level 1 + process state
3 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 session
2 process
3 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

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 MinimumSCN
SCN MAX MaximumSCN
TIME MIN MinimumTime
TIME MAX MaximumTime
LAYER Layer
OPCODE Opcode
DBA MIN FileNumber . BlockNumber
DBA MAX FileNumber . BlockNumber
RBA MIN LogFileSequenceNumber . BlockNumber
RBA 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’;
1 dump控制文件中最早和最迟的日志历史项
1 dump 2^n个日志历史项

三, Trace 文件使用示例

udump下的trc文件可以通过配置不让产生,利用命令
alter system set sql_trace=false;
其他的不能修改,只能手动的启动trace,手动的关闭trace.

比如:
alter session set events 'immediate trace name library_cache|controlf|systemstate|processstate|file_hdrs|REDOHDR level 10';
alter session set events 'immediate trace name off';

alter session set events '10046 trace name context forever,level 12';
alter session set events '10046 trace name context off';

alter system set events '10046 trace name context forever,level 12';
alter system set events '10046 trace name context off';

1. 使用autotrace:

set autotrace ON | ON EXPLAIN | ON STATISTICS | TRACEONLY | TRACEONLY EXPLAIN
set autotrace off
这个用法是最简单方便的,执行sql结束之后,会自动在同个窗口显示sql的执行计划和统计信息。

2. 使用set events context :

SQL> alter session set sql_trace=true;
SQL> alter session set sql_trace=false;
属于当前session级设置
大多数的情况下,我们使用sql_trace跟踪当前进程。通过跟踪当前进程可以发现当前操作的后台数据库递归活动(这在研究数据库新特性时尤其有效),研究SQL执行,发现后台错误等。

alter session set events '10046 trace name context forever,level 12';
alter session set events '10046 trace name context off';
10046事件概述:
10046事件是Oracle提供的内部事件,是对SQL_TRACE的增强.
10046事件可以设置以下四个级别:
1 - 启用标准的SQL_TRACE功能,等价于sql_trace
4 - Level 1 加上绑定值(bind values)
8 - Level 1 + 等待事件跟踪
12 - Level 1 + Level 4 + Level 8
类似sql_trace,10046事件可以在全局设置,也可以在session级设置。

3. 使用set events immediate

alter session set events 'immediate trace name library_cache|controlf|systemstate|processstate|file_hdrs|REDOHDR level 10';
alter session set events 'immediate trace name off';
Level =1 ,转储Library cache统计信息
Level =2 ,转储hash table概要
Level =4 ,转储Library cache对象,只包含基本信息
Level =8 ,转储Library cache对象,包含详细信息(包括child references,pin waiters等)
Level =16,增加heap sizes信息
Level =32,增加heap信息

9i清理buffer cache

alter session set events 'immediate trace name flush_cache level 1';
alter session set events = 'immediate trace name flush_cache'

4. 使用set events errorstack

alter session set events 'err_num trace name errorstack level 10';
alter session set events 'err_num trace name errorstack off'
err_num=报错代码,如ORA-00942 应该在err_num填入942

5. 使用dbms_support(trace别的session):

exec dbms_support.start_trace_in_session(sid=>XX,seiral#=>XXX,wait=>true,binds=>true);
exec dbms_support.stop_trace_in_session(sid=>XX,seiral#=>XXX);
这类trace用到很少,以后再研究。

6. 使用oradebug(trace别的session):

oradebug setospid (PID 能从ps -ef 中得出)
oradebug unlimit
oradebug event 10046 trace name context forever,level 12;
oradebug event 10046 trace name context off;
这类同样用到很少。

7. 使用dbms_system.set_ev:

exec dbms_system.set_ev(sid,serial#,10046,trace_level,'username');
exec dbms_system.set_ev(sid,serial#,10046,0,'username');
通过DBMS_SYSTEM.SET_EV系统包来实现对sql的跟踪

Oracle 跟踪事件 set event

Reference: http://blog.csdn.net/tianlesoftware/article/details/4977827

一、Oracle跟踪文件

Oracle跟踪文件分为三种类型,一种是后台报警日志文件,记录数据库在启动、关闭和运行期间后台进程的活动情况,如表空间创建、回滚段创建、某些alter命令、日志切换、错误消息等。在数据库出现故障时,应首先查看该文件,但文件中的信息与任何错误状态没有必然的联系。后台报警日志文件保存BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为SIDALRT.LOG。另一种类型是DBWR、LGWR、SMON等后台进程创建的后台跟踪文件。后台跟踪文件根据后台进程运行情况产生,后台跟踪文件也保存在BACKGROUND_DUMP_DEST参数指定的目录中,文件格式为siddbwr.trc、sidsmon.trc等。还有一种类型是由连接到Oracle的用户进程(Server Processes)生成的用户跟踪文件。这些文件仅在用户会话期间遇到错误时产生。此外,用户可以通过执行oracle跟踪事件(见后面)来生成该类文件,用户跟踪文件保存在USER_DUMP_DEST参数指定的目录中,文件格式为oraxxxxx.trc,xxxxx为创建文件的进程号(或线程号)。

二、Oracle跟踪事件

Oracle提供了一类命令,可以将Oracle各类内部结构中所包含的信息转储(dump)到跟踪文件中,以便用户能根据文件内容来解决各种故障。设置跟踪事件有两种方法,一种是在init.ora文件中设置事件,这样open数据库后,将影响到所有的会话。设置格式如下:
EVENT="eventnumber trace name eventname [forever,] [level levelnumber] : ……."
通过:符号,可以连续设置多个事件,也可以通过连续使用event来设置多个事件。
另一种方法是在会话过程中使用alter session set events命令,只对当前会话有影响。设置格式如下:
alter session set events '[eventnumber|immediate] trace name eventname [forever] [, level levelnumber] : …….'
通过:符号,可以连续设置多个事件,也可以通过连续使用alter session set events 来设置多个事件。
格式说明:eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,内部事件号在10000到10999之间,不能与immediate关键字同用。
immediate关键字表示命令发出后,立即将指定的结构dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与 eventnumber、forever关键字同用。
trace name 是关键字。
eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。
forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。
level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。
levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息。

1、buffers事件:dump SGA缓冲区中的db buffer结构

alter session set events 'immediate trace name buffers level 1'; —表示dump缓冲区的头部。

2、blockdump事件:dump数据文件、索引文件、回滚段文件结构

alter session set events 'immediate trace name blockdump level 66666'; —表示dump块地址为6666的数据块。
在Oracle 8以后该命令已改为:
alter system dump datafile 11 block 9; —表示dump数据文件号为11中的第9个数据块。

3、controlf事件:dump控制文件结构

alter session set events 'immediate trace name controlf level 10'; —表示dump控制文件的所有内容。

4、locks事件:dump LCK进程的锁信息

alter session set events 'immediate trace name locks level 5';

5、redohdr事件:dump redo日志的头部信息

alter session set events 'immediate trace name redohdr level 1'; —表示dump redo日志头部的控制文件项。
alter session set events 'immediate trace name redohdr level 2'; —表示dump redo日志的通用文件头。
alter session set events 'immediate trace name redohdr level 10'; —表示dump redo日志的完整文件头。
注意:redo日志的内容dump可以采用下面的语句:
alter system dump logfile 'logfilename';

6、loghist事件:dump控制文件中的日志历史项

alter session set events 'immediate trace name loghist level 1'; —表示只dump最早和最迟的日志历史项。
levelnumber大于等于2时,表示2的levelnumber次方个日志历史项。
alter session set events 'immediate trace name loghist level 4'; —表示dump 16个日志历史项。

7、file_hdrs事件:dump 所有数据文件的头部信息

alter session set events 'immediate trace name file_hdrs level 1'; —表示dump 所有数据文件头部的控制文件项。
alter session set events 'immediate trace name file_hdrs level 2'; —表示dump 所有数据文件的通用文件头。
alter session set events 'immediate trace name file_hdrs level 10'; —表示dump 所有数据文件的完整文件头。

8、errorstack事件:dump 错误栈信息

dump 错误栈信息,通常Oracle发生错误时前台进程将得到一条错误信息,但某些情况下得不到错误信息,可以采用这种方式得到Oracle错误。
alter session set events '604 trace name errorstack forever'; —表示当出现604错误时,dump 错误栈和进程栈。

9、systemstate事件:dump所有系统状态和进程状态

alter session set events 'immediate trace name systemstate level 10'; —表示dump 所有系统状态和进程状态。

10、coalesec事件:dump指定表空间中的自由区间

levelnumber以十六进制表示时,两个高位字节表示自由区间数目,两个低位字节表示表空间号,如0x00050000表示dump系统表空间中的5个自由区间,转换成十进制就是327680,即:
alter session set events 'immediate trace name coalesec level 327680';

11、processsate事件:dump进程状态

alter session set events 'immediate trace name processsate level 10';

12、library_cache事件:dump library cache信息

alter session set events 'immediate trace name library_cache level 10';

13、heapdump事件:dump PGA、SGA、UGA中的信息

alter session set events 'immediate trace name heapdump level 1';

14、row_cache事件:dump数据字典缓冲区中的信息

alter session set events 'immediate trace name row_cache level 1';

三、内部事件号

1、10013:用于监视事务恢复

2、10015:转储UNDO SEGMENT头部
event = "10015 trace name context forever"

3、10029:用于给出会话期间的登陆信息

4、10030:用于给出会话期间的注销信息

5、10032:转储排序的统计信息

6、10033:转储排序增长的统计信息

7、10045:跟踪Freelist管理操作

8、10046:跟踪SQL语句
alter session set events '10046 trace name context forever, level 4'; —跟踪SQL语句并显示绑定变量
alter session set events '10046 trace name context forever, level 8'; —跟踪SQL语句并显示等待事件

9、10053:转储优化策略

10、10059:模拟redo日志中的创建和清除错误

11、10061:阻止SMON进程在启动时清除临时段

12、10079:转储 SQL*NET统计信息

13、10081:转储高水标记变化

14、10104:转储Hash连接统计信息

15、10128:转储分区休整信息

16、10200:转储一致性读信息

17、10201:转储一致性读中Undo应用

18、10209:允许在控制文件中模拟错误

19、10210:触发数据块检查事件
event = "10210 trace name context forever, level 10"

20、10211:触发索引检查事件

21、10213:模拟在写控制文件后崩溃

22、10214:模拟在控制文件中的写错误
levelnumber从1-9表示产生错误的块号,大于等于10则每个控制文件将出错

23、10215:模拟在控制文件中的读错误

24、10220:转储Undo头部变化

25、10221;转储Undo变化

26、10224:转储索引的分隔与删除

27、10225:转储基于字典管理的区间的变化

28、10229:模拟在数据文件上的I/O错误

29、10231:设置在全表扫描时忽略损坏的数据块
alter session set events '10231 trace name context off'; — 关闭会话期间的数据块检查
event = "10231 trace name context forever, level 10" — 对任何进程读入SGA的数据块进行检查

30、10232:将设置为软损坏(DBMS_REPAIR包设置或DB_BLOCK_CHECKING为TRUE时设置)的数据块dump到跟踪文件

31、10235:用于内存堆检查
alter session set events '10235 trace name context forever, level 1';

32、10241:转储远程SQL执行

33、10246:跟踪PMON进程

34、10248:跟踪dispatch进程

35、10249:跟踪MTS进程

36、10252:模拟写数据文件头部错误

37、10253:模拟写redo日志文件错误

38、10262:允许连接时存在内存泄漏
alter session set events '10262 trace name context forever, level 300'; — 允许存在300个字节的内存泄漏

39、10270:转储共享游标

40、10285:模拟控制文件头部损坏

41、10286:模拟控制文件打开错误

42、10287:模拟归档出错

43、10357:调试直接路径机制

44、10500:跟踪SMON进程

45、10608:跟踪位图索引的创建

46、10704:跟踪enqueues

47、10706:跟踪全局enqueues

48、10708:跟踪RAC的buffer cache

49、10710:跟踪对位图索引的访问

50、10711:跟踪位图索引合并操作

51、10712:跟踪位图索引OR操作

52、10713:跟踪位图索引AND操作

53、10714:跟踪位图索引MINUS操作

54、10715:跟踪位图索引向ROWID的转化

55、10716:跟踪位图索引的压缩与解压

56、10719:跟踪位图索引的修改

57、10731:跟踪游标声明

58、10928:跟踪PL/SQL执行

59、10938:转储PL/SQL执行统计信息
最后要说明的是,由于版本不同以上语法可能有些变化,但大多数还是可用的。

Oracle Trace Level Event Numbers

http://dbanotes.net/database/oracle_trace_level_event_numbers.html

10000 control file debug event, name 'control_file'
10001 control file crash event1
10002 control file crash event2
10003 control file crash event3
10004 control file crash event4
10005 trace latch operations for debugging
10006 testing - block recovery forced
10007 log switch debug crash after new log select, thread %s
10008 log switch debug crash after new log header write, thread %s
10009 log switch debug crash after old log header write, thread %s
10010 Begin Transaction
10011 End Transaction
10012 Abort Transaction
10013 Instance Recovery
10014 Roll Back to Save Point
10015 Undo Segment Recovery
10016 Undo Segment extend
10017 Undo Segment Wrap
10018 Data Segment Create
10019 Data Segment Recovery
10020 partial link restored to linked list (KSG)
10021 latch cleanup for state objects (KSS)
10022 trace ktsgsp
10023 Create Save Undo Segment
10024 Write to Save Undo
10025 Extend Save Undo Segment
10026 Apply Save Undo
10027 latch cleanup for enqueue locks (KSQ)
10028 latch cleanup for enqueue resources (KSQ)
10029 session logon (KSU)
10030 session logoff (KSU)
10031 row source debug event (R*)
10032 sort end (SOR*)
10035 parse SQL statement (OPIPRS)
10036 create remote row source (QKANET)
10037 allocate remote row source (QKARWS)
10038 dump row source tree (QBADRV)
10039 type checking (OPITCA)
10040 dirty cache list
10041 dump undo records skipped
10042 trap error during undo application
10044 free list undo operations
10045 "free list update operations - ktsrsp, ktsunl"
10046 enable SQL statement timing
10047 trace switching of sessions
10048 Undo segment shrink
10049 protect library cache memory heaps
10050 sniper trace
10051 trace OPI calls
10052 don't clean up obj$
10053 CBO Enable optimizer trace
10054 trace UNDO handling in MLS
10055 trace UNDO handing
10056 dump analyze stats (kdg)
10057 suppress file names in error messages
10058 use table scan cost in tab$.spare1
10060 CBO Enable predicate dump
10061 disable SMON from cleaning temp segment
10062 disable usage of OS Roles in osds
10063 disable usage of DBA and OPER privileges in osds
10064 "thread enable debug crash level %s, thread %s"
10065 limit library cache dump information for state object dump
10066 simulate failure to verify file
10067 force redo log checksum errors - block number
10068 force redo log checksum errors - file number
10069 Trusted Oracle test event
10070 force datafile checksum errors - block number
10071 force datafile checksum errors - file number
10072 protect latch recovery memory
10073 have PMON dump info before latch cleanup
10074 default trace function mask for kst
10075 CBO Disable outer-join to regular join conversion
10076 CBO Enable cartesian product join costing
10077 CBO Disable view-merging optimization for outer-joins
10078 CBO Disable constant predicate elimination optimization
10080 dump a block on a segment list which cannot be exchanged
10081 segment High Water Mark has been advanced
10082 free list head block is the same as the last block
10083 a brand new block has been requested from space management
10084 free list becomes empty
10085 free lists have been merged
10086 CBO Enable error if kko and qka disagree on oby sort
10087 disable repair of media corrupt data blocks
10088 CBO Disable new NOT IN optimization
10089 CBO Disable index sorting
10090 invoke other events before crash recovery
10091 CBO Disable constant predicate merging
10092 CBO Disable hash join
10093 CBO Enable force hash joins
10094 before resizing a data file
10095 dump debugger commands to trace file
10096 after the cross instance call when resizing a data file
10097 after generating redo when resizing a data file
10098 after the OS has increased the size of a data file
10099 after updating the file header with the new file size
10100 after the OS has decreased the size of a data file
10101 atomic redo write recovery
10102 switch off anti-joins
10103 CBO Disable hash join swapping
10104 dump hash join statistics to trace file
10105 CBO Enable constant pred trans and MPs w WHERE-clause
10106 CBO Disable evaluating correlation pred last for NOT IN
10107 CBO Always use bitmap index
10108 CBO Don't use bitmap index
10109 CBO Disable move of negated predicates
10110 CBO Try index rowid range scans
10111 Bitmap index creation switch
10112 Bitmap index creation switch
10113 Bitmap index creation switch
10114 Bitmap index creation switch
10115 CBO Bitmap optimization use maximal expression
10116 CBO Bitmap optimization switch
10117 CBO Disable new parallel cost model
10118 CBO Enable hash join costing
10119 QKA Disable GBY sort elimination
10120 CBO Disable index fast full scan
10121 CBO Don't sort bitmap chains
10122 CBO disable count(col) => count(*) transformation
10123 QKA Disable Bitmap And-EQuals
10145 test auditing network errors
10146 enable Oracle TRACE collection
10200 block cleanout
10201 consistent read undo application
10202 consistent read block header
10203 consistent read buffer status
10204 signal recursive extend
10205 row cache debugging
10206 transaction table consistent read
10207 consistent read transactions' status report
10208 consistent read loop check
10209 enable simulated error on control file
10210 check data block integrity
10211 check index block integrity
10212 check cluster integrity
10213 crash after control file write
10214 simulate write errors on control file
10215 simulate read errors on control file
10216 dump control file header
10217 debug sequence numbers
10218 dump uba of applied undo
10219 monitor multi-pass row locking
10220 show updates to the transaction table
10221 show changes done with undo
10222 row cache
10223 transaction layer - turn on verification codes
10226 trace CR applications of undo for data operations
10227 verify (multi-piece) row structure
10228 trace application of redo by kcocbk
10230 check redo generation by copying before applying
10231 skip corrupted blocks on _table_scans_
10232 dump corrupted blocks symbolically when kcbgotten
10233 skip corrupted blocks on index operations
10234 trigger event after calling kcrapc to do redo N times
10235 check memory manager internal structures
10236 library cache manager
10237 simulate ^C (for testing purposes)
10238 instantiation manager
10239 multi-instance library cache manager
10240 dump dba's of blocks that we wait for
10241 dump SQL generated for remote execution (OPIX)
10243 simulated error for test %s of K2GTAB latch cleanup
10244 make tranids in error msgs print as 0.0.0 (for testing)
10245 simulate lock conflict error for testing PMON
10246 print trace of PMON actions to trace file
10247 Turn on scgcmn tracing. (VMS ONLY)
10248 turn on tracing for dispatchers
10249 turn on tracing for multi-stated servers
10250 Trace all allocate and free calls to the topmost SGA heap
10251 check consistency of transaction table and undo block
10252 simulate write error to data file header
10253 simulate write error to redo log
10254 trace cross-instance calls
10256 turn off multi-threaded server load balancing
10257 trace multi-threaded server load balancing
10258 force shared servers to be chosen round-robin
10259 get error message text from remote using explicit call
10260 Trace calls to SMPRSET (VMS ONLY)
10261 Limit the size of the PGA heap
10262 Don't check for memory leaks
10263 Don't free empty PGA heap extents
10264 Collect statistics on context area usage (x$ksmcx)
10265 Keep random system generated output out of error messages
10266 Trace OSD stack usage
10267 Inhibit KSEDMP for testing
10268 Don't do forward coalesce when deleting extents
10269 Don't do coalesces of free space in SMON
10270 Debug shared cursors
10271 distributed transaction after COLLECT
10272 distributed transaction before PREPARE
10273 distributed transaction after PREPARE
10274 distributed transaction before COMMIT
10275 distributed transaction after COMMIT
10276 distributed transaction before FORGET
10277 Cursor sharing (or not) related event (used for testing)
10281 maximum time to wait for process creation
10282 Inhibit signalling of other backgrounds when one dies
10286 Simulate control file open error
10287 Simulate archiver error
10288 Do not check block type in ktrget
10289 Do block dumps to trace file in hex rather than fromatted
10290 kdnchk - checkvalid event - not for general purpose use.
10291 die in dtsdrv to test controlfile undo"
10292 dump uet entries on a 1561 from dtsdrv"
10293 dump debugging information when doing block recovery"
10294 enable PERSISTENT DLM operations on non-compliant systems"
10300 disable undo compatibility check at database open
10301 Enable LCK timeout table consistency check"
10320 Enable data layer (kdtgrs) tracing of space management calls"
10352 report direct path statistics
10353 number of slots
10354 turn on direct read path for parallel query
10355 turn on direct read path for scans
10356 turn on hint usage for direct read
10357 turn on debug information for direct path
10374 parallel query server interrupt (validate lock value)
10375 turn on checks for statistics rollups
10376 turn on table queue statistics
10377 turn off load balancing
10379 direct read for rowid range scans (unimplemented)
10380 kxfp latch cleanup testing event
10381 kxfp latch cleanup testing event
10382 parallel query server interrupt (reset)
10383 auto parallelization testing event
10384 parallel dataflow scheduler tracing
10385 parallel table scan range sampling method
10386 parallel SQL hash and range statistics
10387 parallel query server interrupt (normal)
10388 parallel query server interrupt (failure)
10389 parallel query server interrupt (cleanup)
10390 Trace parallel query slave execution
10391 trace rowid range partitioning
10392 parallel query debugging bits
10393 print parallel query statistics
10394 allow parallelization of small tables
10395 adjust sample size for range table queues
10396 circumvent range table queues for queries
10397 suppress verbose parallel coordinator error reporting
10398 enable timeouts in parallel query threads
10399 use different internal maximum buffer size
10400 turn on system state dumps for shutdown debugging
10500 turn on traces for SMON
10510 turn off SMON check to offline pending offline rollbacksegment
10511 turn off SMON check to cleanup undo dictionary
10512 turn off SMON check to shrink rollback segments
10600 check cursor frame allocation
10602 cause an access violation (for testing purposes)
10603 cause an error to occur during truncate (for testing purposes)
10604 trace parallel create index
10605 enable parallel create index by default
10606 trace parallel create index
10607 trace index rowid partition scan
10608 trace create bitmap index
10610 trace create index pseudo optimizer
10666 Do not get database enqueue name
10667 Cause sppst to check for valid process ids
10690 Set shadow process core file dump type (Unix only)
10691 Set background process core file type (Unix only)
10700 Alter access violation exception handler
10701 Dump direct loader index keys
10702 Enable histogram data generation
10703 Simulate process death during enqueue get
10704 Print out information about what enqueues are being obtained
10706 Print out information about instance lock manipulation
10707 Simulate process death for instance registration
10708 Print out Tracing information for skxf multi instance comms
10709 enable parallel instances in create index by default
10710 trace bitmap index access
10711 trace bitmap index merge
10712 trace bitmap index or
10713 trace bitmap index and
10714 trace bitmap index minus
10715 trace bitmap index conversion to rowids
10800 disable Smart Disk scan
10801 enable Smart Disk trace
10802 reserved for Smart Disk
10803 write timing statistics on OPS recovery scan
10804 reserved for ksxb
10805 reserved for row source sort
10900 extent manager fault insertion event #%s
10924 import storage parse error ignore event
10925 trace name context forever
10926 trace name context forever
10927 trace name context forever
10928 trace name context forever
10999 do not get database enqueue name

Oracle Trace: The Swiss Army Knife of Diagnostic Tools
Setting Events
Trace and TKPROF

四. 示例

4.1 查看当前trc 文件

select
u_dump.value || '/' ||
db_name.value || '_ora_' ||
v$process.spid ||
nvl2(v$process.traceid, '_' || v$process.traceid, null )

from
v$parameter u_dump
cross join v$parameter db_name
cross join v$process
join v$session
on v$process.addr = v$session.paddr
where
u_dump.name = 'user_dump_dest' and
db_name.name = 'db_name' and
v$session.audsid=sys_context('userenv','sessionid');
eg:
/fsdb1/oracle/admin/newccs/udump/newccs_ora_4862050.trc

4.2 执行event

alter session set events '10046 trace name context forever, level 1';
select count(1) from all_tables;
alter session set events '10046 trace name context off' ;

4.3 在查看newccs_ora_4862050.trc

$more newccs_ora_4862050.trc