分类: Oracle
2009-06-03 22:51:49
例子:
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 EYGLE
设置跟着:
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.