ITPub博客

首页 > 数据库 > Oracle > oracle 跟踪当前用户会话

oracle 跟踪当前用户会话

原创 Oracle 作者:chenoracle 时间:2015-06-08 15:45:27 0 删除 编辑
跟踪当前用户会话


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
********************************************************************************


欢迎关注我的微信公众号"IT小Chen",共同学习,共同成长!!!



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29785807/viewspace-1691680/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 触发器详解
请登录后发表评论 登录
全部评论
Oracle ACE、OCMU 用户组成员、Oracle 11g OCM、微信公众号"IT小Chen"

注册时间:2014-08-05

  • 博文量
    853
  • 访问量
    2727959