denrepo

OracleDiagnostics

Trace another session with waits and binds

Prompts for a SID and serial number, turns on extended SQL trace, and shows the trace file name. Run the disable line when you've captured enough, then format the file with tkprof.

Changes dataPrompts for input

Not yet verified. How scripts are tested

This script changes the database. Check the names and values before you run it.
ora-trace-session.sql
1SET VERIFY OFF LINESIZE 2002COLUMN tracefile FORMAT A1203 4EXEC DBMS_MONITOR.SESSION_TRACE_ENABLE(session_id => &&sid, serial_num => &&serial, waits => TRUE, binds => TRUE);5 6SELECT p.tracefile7FROM v$session s8JOIN v$process p ON p.addr = s.paddr9WHERE s.sid = &&sid;10 11-- When you have enough, run this in the same SQL*Plus session:12-- EXEC DBMS_MONITOR.SESSION_TRACE_DISABLE(session_id => &&sid, serial_num => &&serial);13-- UNDEFINE sid serial

Save it as ora-trace-session.sql and run it with SQL> @ora-trace-session.

Open in denrepo

More Oracle scripts: Diagnostics