Site icon Database Tutorials

Enable Trace For a Session in Oracle

You may need to enable trace for a session for many reasons. For example, you may need to determine which queries run in a session.

You can enable trace for a session with the DBMS_MONITOR.session_trace_enable procedure. Use of the procedure and the parameters it passes are as follows.

Example

Enable Trace

The following command can be used to start trace for a session with session id 1153.

If “binds => TRUE” is not specified, the variables used during the session will not be written. Therefore, “binds => TRUE” must be specified.

Trace Directory Information

We can find the trace directory information with the following query.

Disable Trace

We can use the DBMS_MONITOR.SESSION_TRACE_DISABLE procedure to disable the trace process.

We can disable the trace we have enabled as follows.

Read Trace File

The contents of the trace file will be as follows.

Exit mobile version