- 最后登录
- 2015-4-9
- 在线时间
- 114 小时
- 威望
- 334
- 金钱
- 9852
- 注册时间
- 2011-11-16
- 阅读权限
- 60
- 帖子
- 158
- 精华
- 0
- 积分
- 334
- UID
- 94
|
1#
发表于 2012-12-6 01:03:38
|
查看: 4908 |
回复: 4
问题1 v$session.sql_trace 标示的是什么?文档中写Indicates whether SQL tracing is enabled (ENABLED) or disabled (DISABLED)
问题2 如何判断session的trace是打开的?
下面是自己测试的过程 ,有点晕。 请刘大指点。。3Q
在11.2.0.1.0中, v$session.sql_trace和dbms_system执行的结果都显示trace是关着的
C:\Users\Thinkpad>sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 12月 6 00:31:18 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> conn /as sysdba
已连接。
SQL> select * from v$mystat where rownum=1;
SID STATISTIC# VALUE
---------- ---------- ----------
73 0 0
SQL> set serveroutput on
SQL> select sql_trace from v$session where sid=73;
SQL_TRAC
--------
DISABLED
SQL> alter session set sql_trace=true;
会话已更改。
SQL> declare
2 l_event number;
3 begin
4 sys.dbms_system.read_ev( 10046, l_event );
5 dbms_output.put_line( 'result = ' || l_event );
6 end;
7 /
result = 0
PL/SQL 过程已成功完成。
SQL> select sql_trace from v$session where sid=73;
SQL_TRAC
--------
DISABLED
SQL> alter session set events '10046 trace name context forever, level 12';
会话已更改。
SQL> declare
2 l_event number;
3 begin
4 sys.dbms_system.read_ev( 10046, l_event );
5 dbms_output.put_line( 'result = ' || l_event );
6 end;
7 /
result = 0
PL/SQL 过程已成功完成。
SQL> select sql_trace from v$session where sid=73;
SQL_TRAC
--------
DISABLED
在10G中 v$session.sql_trace显示trace是关着的, dbms_system显示trace是开着(对alter session set sql_trace不适用)
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> conn /as sysdba
Connected.
SQL> select * from v$mystat where rownum=1;
SID STATISTIC# VALUE
---------- ---------- ----------
159 0 1
SQL> select sql_trace from v$session where sid=159;
SQL_TRAC
--------
DISABLED
SQL> set serveroutput on
SQL> declare
2 l_event number;
3 begin
4 sys.dbms_system.read_ev( 10046, l_event );
5 dbms_output.put_line( 'result = ' || l_event );
6 end;
7 /
result = 0
PL/SQL procedure successfully completed.
SQL> alter session set sql_trace=true;
Session altered.
SQL> select sql_trace from v$session where sid=159;
SQL_TRAC
--------
DISABLED
SQL> declare
2 l_event number;
3 begin
4 sys.dbms_system.read_ev( 10046, l_event );
5 dbms_output.put_line( 'result = ' || l_event );
6 end;
7 /
result = 0
PL/SQL procedure successfully completed.
SQL> alter session set events '10046 trace name context forever, level 8';
Session altered.
SQL> select sql_trace from v$session where sid=159;
SQL_TRAC
--------
DISABLED
SQL> declare
2 l_event number;
3 begin
4 sys.dbms_system.read_ev( 10046, l_event );
5 dbms_output.put_line( 'result = ' || l_event );
6 end;
7 /
result = 8 --这里显示10046 level 8
PL/SQL procedure successfully completed. |
|