====== [HOWTO] Trace any sql ======
====== Original documentation ======
[[https://smarttechways.com/2018/12/10/trace-the-sql-query-with-sql-id-in-oracle/|Trace the SQL Query with SQL ID in Oracle]]
====== Instructions ======
Identify your SQL ID of SQL Query which need to trace.
SELECT sql_id, plan_hash_value, substr(sql_text,1,40) sql_text
FROM v$sql
WHERE sql_text like 'SQL QUERY%';
Enable the trace of SQL with using '''' in following statements:
alter system set events 'sql_trace [sql:] wait=true,bind=true';
alter system set events 'trace[sql_optimizer.*] [sql:]';
\\
Disable tracing:
alter system set events 'sql_trace off';
alter system set events 'trace[sql_optimizer.*] off';