*************************************************************
1.开启10046
*************************************************************
SQL> oradebug setmypid
Statement processed.
// 激活 10046 事件
SQL> oradebug event 10046 trace name context forever,level 12;
Statement processed.
SQL> select count(*) from scott.tblorders;
COUNT(*)
----------
167
// 在当前 session 关闭 10046 事件
SQL> oradebug event 10046 trace name context off;
Statement processed.
// 使用 oradebug tracefile_name 可以直接看到生成的 trace 文件的位置
SQL> oradebug tracefile_name;
/u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2551.trc
*************************************************************
2.直接读取文件
*************************************************************
----------------------trace文件内容
Trace file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2551.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name: Linux
Node name: timesten.ocp.com
Release: 2.6.32-431.el6.x86_64
Version: #1 SMP Fri Nov 22 03:15:09 UTC 2013
Machine: x86_64
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 20
Unix process pid: 2551, image: [email protected] (TNS V1-V3)
*** 2015-02-10 17:34:40.127
*** SESSION ID:(132.9911) 2015-02-10 17:34:40.127
*** CLIENT ID:() 2015-02-10 17:34:40.127
*** SERVICE NAME:(SYS$USERS) 2015-02-10 17:34:40.127
*** MODULE NAME:([email protected] (TNS V1-V3)) 2015-02-10 17:34:40.127
*** ACTION NAME:() 2015-02-10 17:34:40.127
Processing Oradebug command 'setmypid'
*** 2015-02-10 17:34:40.127
Oradebug command 'setmypid' console output: <none>
*** 2015-02-10 17:34:48.483
Processing Oradebug command 'event 10046 trace name context forever,level 12'
*** 2015-02-10 17:34:48.484
Oradebug command 'event 10046 trace name context forever,level 12' console output: <none>
WAIT #0: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1423560888484461
*** 2015-02-10 1
10046入门:使用 10046 查看执行计划并读懂 trace文件
最新推荐文章于 2025-06-21 17:13:43 发布