SQL> select sid,serial#,username,status from v$session where username='TEST';
SID SERIAL# USERNAME
---------- ---------- ------------------------------
124 26742 TEST
方法一:
执行跟踪:
SQL> exec dbms_system.set_ev(148,2028,10046,8,''); ------------注意最后一个参数'',必须是这样的,而没有用户名
结束跟踪:
SQL> exec dbms_system.set_ev(148,2028,10046,0,'');
方法二:
SQL> select sid,serial#,username,status from v$session where username ='TEST';
SID SERIAL# USERNAME STATUS
---------- ---------- ------------------------------ --------
124 26742 TEST KILLED
140 61014 TEST INACTIVE
148 2028 TEST KILLED
Session 1:
conn /as sysdba
exec dbms_system.set_ev(140,61014,10046,8,'test');
执行了这一步以后 只是对其他的会话设置了跟踪事件的等级,并非开始跟踪
开始跟踪
exec dbms_system.set_sql_trace_in_session(140,61014,true);
....
在Session 2:
Conn test/test
中执行SQL 语句:
Select count(*) from user_tables;
Session 1:
结束跟踪
exec dbms_system.set_sql_trace_in_session(140,61014,false);
关闭会话设置
exec dbms_system.set_ev(140,61014,10046,0,'test');
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27036311/viewspace-753361/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27036311/viewspace-753361/