So this question was asked to me a few months back in one of my presentations. "How do I find a trace file from SQL trace on my Oracle Database?"
Sorry for the delay, but here are my suggestions. First, you will need to know where your trace file will be located. By default, it will be in the trace directory as part of the diagnostic destination. Make sure you know where your diagnostic destination is located.
SQL> show parameter diag
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
diagnostic_dest string /u01/app/oracle
There are basically three four main ways to find your trace file.
Well, I learned something new, so I wanted to update this article. There is a view you can directly query to see your current trace file name.
SELECT value
FROM v$diag_info
WHERE name = 'Default Trace File';
This will show the correct trace file name when you update your TRACEFILE_IDENTIFER. So I would still recommend setting that as outlined in Option 1.
For this option, we set a session-level parameter to drive the name of the trace file.
ALTER SESSION SET tracefile_identifier = 'SQLID_fua0hb5hfst77';
EXEC DBMS_SESSION.SET_SQL_TRACE(sql_trace => true);
SELECT sum(t1.c), sum(t2.c)
FROM t1, t2
WHERE t1.a = t2.a
AND t1.d = 10;
Then disable the tracing:
EXEC DBMS_SESSION.SET_SQL_TRACE(sql_trace => false);
cd /u01/app/oracle/diag/rdbms/t1db/t1db/trace/
[oracle@srvr03 trace]$ ls -ltrh *fua0*
-rw-r----- 1 oracle oinstall 4.3K Feb 5 08:29 t1db_ora_4978_SQLID_fua0hb5hfst77.trc
-rw-r----- 1 oracle oinstall 2.0K Feb 5 08:29 t1db_ora_4978_SQLID_fua0hb5hfst77.trm
ALTER SESSION SET EVENTS '10053 trace name context forever, level 1'; -- CBO tracing
ALTER SESSION SET EVENTS '10046 trace name context forever, level 12'; -- Additional SQL trace information
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
max_dump_file_size string unlimited
set linesize 100
column name format a20
column value format a70
select name, value from v$diag_info where name = 'Default Trace File';
NAME VALUE
-------------------- ----------------------------------------------------------------------
Default Trace File /u01/app/oracle/diag/rdbms/t1db/t1db/trace/t1db_ora_31523.trc
SQL> select userenv('SID') from dual;
USERENV('SID')
--------------
19
find /u01/app/oracle/diag/rdbms/t1db/t1db/trace -name t1db_ora\*.trc -mtime 0 -exec grep -l "*** SESSION ID:(19." {} \;
/u01/app/oracle/diag/rdbms/t1db/t1db/trace/t1db_ora_26655.trc
/u01/app/oracle/diag/rdbms/t1db/t1db/trace/t1db_ora_4978_SQLID_fua0hb5hfst77_.trc
/u01/app/oracle/diag/rdbms/t1db/t1db/trace/t1db_ora_31523.trc
/u01/app/oracle/diag/rdbms/t1db/t1db/trace/t1db_ora_14396.trc