跟踪当前用户会话
SQL> show parameter sql_trace
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sql_trace boolean FALSE
指定跟踪文件名
SQL> alter session set tracefile_identifier='chen';
Session altered
开启跟踪
SQL> alter session set sql_trace=true;
Session altered
SQL> show parameter user_dump_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string /u2/app/oracle/diag/rdbms/orcl/orcl/trace
[oracle@localhost trace]$ pwd
/u2/app/oracle/diag/rdbms/orcl/orcl/trace
[oracle@localhost trace]$ ll -rth
......
-rw-r----- 1 oracle11 oinstall 346 06-08 13:33 orcl_ora_27268_chen.trm
-rw-r----- 1 oracle11 oinstall 136K 06-08 13:33 orcl_ora_27268_chen.trc
关闭跟踪
SQL> alter session set sql_trace=false;
Session altered
使用tkprof工具使跟踪文件更易读
[oracle@localhost trace]$ tkprof orcl_ora_27268_chen.trc /home/oracle/chen.prf
TKPROF: Release 9.0.1.0.0 - Production on Mon Jun 8 14:22:21 2015
(c) Copyright 2001 Oracle Corporation. All rights reserved.
[oracle@localhost trace]$ vim /home/oracle/chen.prf
......
********************************************************************************
create table cc(id number)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 2 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 2 0
Misses in library cache during parse: 1
Optimizer goal: ALL_ROWS
Parsing user id: 112
********************************************************************************
********************************************************************************
alter session set sql_trace=false
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 1
Optimizer goal: ALL_ROWS
Parsing user id: 112
********************************************************************************
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29785807/viewspace-1691680/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29785807/viewspace-1691680/