1:针对其他用户的sql_trace跟踪
- C:\>sqlplus hr/hr@192.168.123.13:1521/dg53.yang.com
- SQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 8 14:46:33 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to:
- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, OLAP and Data Mining options
- SQL> show user;
- USER is "HR"
- SQL> show user;
- USER is "SYS"
- SQL> select sid,serial# from v$session where username='HR';
- SID SERIAL#
- ---------- ----------
- 129 55
- SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid=129 and
- s.serial#=55;
- SPID
- ------------
- 20844
- SQL> exec dbms_system.set_sql_trace_in_session(129,55,true);
- PL/SQL procedure successfully completed.
- SQL> select distinct department_id from departments;
- DEPARTMENT_ID
- -------------
- 10
- 20
- 30
- 40
- SQL> exec dbms_system.set_sql_trace_in_session(129,55,false);
- PL/SQL procedure successfully completed.
- [oracle@dg53 udump]$ tkprof dg53_ora_20844.trc /home/oracle/trace03.log sys=no
- aggregate=yes explain=hr/hr
2:针对其他会话的10046事件的开启和关闭
- SQL> exec dbms_monitor.session_trace_enable(129,55,waits=>true,binds=>true);
- PL/SQL procedure successfully completed.
- SQL> exec dbms_monitor.session_trace_disable(129,55);
- PL/SQL procedure successfully completed
本文以《让oracle跑的更快》为指导,如有雷同,不胜荣幸!
