Amazon books

Thursday, February 20, 2014

Examplos of enabling/disabling TRACE in Oracle sessions

I prefer oradebug but as you can see below there are a lot of ways to enable and disable trace in sessions:

--Get the SPID from v$session and use it below
SQL> oradebug setospid 17039468
SQL> oradebug event 10046 trace name context forever, level 12; --Here you enable
SQL> --Wait for 10 Mins
SQL> oradebug event 10046 trace name context off ; --Here you disable


-- In your session
SQL> ALTER SESSION SET sql_trace=TRUE;
SQL> ALTER SESSION SET sql_trace=FALSE;

SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);

SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';
SQL> ALTER SESSION SET EVENTS '10046 trace name context off';


SQL> EXEC DBMS_MONITOR.session_trace_enable;
SQL> EXEC DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_MONITOR.session_trace_disable;


--In another session or service /module

SQL> EXEC DBMS_MONITOR.session_trace_enable(session_id=>253, serial_num=>45525, waits=>TRUE, binds=>TRUE);
SQL> EXEC DBMS_MONITOR.session_trace_enable(session_id =>1234, serial_num=>1234, waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_MONITOR.session_trace_disable(session_id=>1234, serial_num=>1234);

SQL> EXEC DBMS_MONITOR.client_id_trace_enable(client_id=>'client_id_test');
SQL> EXEC DBMS_MONITOR.client_id_trace_enable(client_id=>'client_id_test', waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_MONITOR.client_id_trace_disable(client_id=>'client_id_test');

SQL> EXEC DBMS_MONITOR.serv_mod_act_trace_enable(service_name=>'db10g', module_name=>'test_api', action_name=>'running');
SQL> EXEC DBMS_MONITOR.serv_mod_act_trace_enable(service_name=>'db10g', module_name=>'test_api', action_name=>'running', -
> waits=>TRUE, binds=>FALSE);
SQL> EXEC DBMS_MONITOR.serv_mod_act_trace_disable(service_name=>'db10g', module_name=>'test_api', action_name=>'running');


Best Regards,
Paulo Portugal

No comments:

Post a Comment