例子:
exec sys.dbms_system.set_sql_trace_in_session(10 , 39196 , true);
exec sys.dbms_system.set_sql_trace_in_session(10 , 39196 , false);
SET_SQL_TRACE_IN_SESSION过程序要提供三个参数:
SQL> desc DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION;
Parameter Type Mode Default?
--------- ------- ---- --------
SID NUMBER IN
SERIAL# NUMBER IN
SQL_TRACE BOOLEAN IN
通过v$session我们可以获得sid、serial#等信息:
获得进程信息,选择需要跟踪的进程:
SQL> select sid,serial#,username from v$session
2 where username is not null;
SID SERIAL# USERNAME
---------- ---------- ------------------------------
8 2041 SYS
9 437 TEST
设置跟着:
SQL> exec dbms_system.set_SQL_TRACE_in_session(9,437,true)
PL/SQL procedure successfully completed.
….
可以等候片刻,跟踪session执行任务,捕获sql操作…
….
停止跟踪:
SQL> exec dbms_system.set_SQL_TRACE_in_session(9,437,false)
PL/SQL procedure successfully completed.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11417069/viewspace-687462/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/11417069/viewspace-687462/