How to Enable User-Level SQL Tracing in Oracle (Both Current and Remote Sessions)
In this article, I’m going to explain user-level SQL tracing in Oracle — a very useful technique when you need to diagnose performance issues or understand what SQL a session is executing.
We’ll look at two scenarios:
- Tracing your own (current) session
- Tracing another user’s session from outside
Most of the time, DBAs trace other sessions, so both approaches are covered below.
1. Tracing the Current Session
You can enable SQL trace in your own session with a simple command.
Start tracing
Note: The user must have
ALTER SESSIONprivilege.
Optional: Add an identifier to the trace file
This makes it easier to find the correct file later:
Find the location of your trace file
Run:
Example output:
2. Tracing Another User’s Session
Sometimes you need to trace a session that is already running. For that, you must identify the session details first.
Find the SID and SERIAL#
Start tracing for that session
Note:
In a RAC environment, run this command on the same node where the session is connected.
Locate the trace file
Stop tracing
Again, on RAC systems, make sure to execute this on the correct instance.

Post a Comment
Post a Comment