【10046 SQL】
conn username/password
alter session set tracefile_identifier = 'id_10046';
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set "_rowsource_execution_statistics" = TRUE;
alter session set events '10046 trace name context forever, level 12';
<Run your SQL here;>
rollback;
alter session set events '10046 trace name context off';
【10046 sql_id】
alter session set tracefile_identifier = 'id_10046';
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set "_rowsource_execution_statistics" = TRUE;
alter system set events 'sql_trace [sql:21jthqydpgzy9] level 12';
alter system set events 'sql_trace [sql:21jthqydpgzy9] off';
--查询trc文件路径
select value from v$diag_info where name='Default Trace File';
--格式化trace
$tkprof DB2_ora_45941130_id_10046.trc DB2_ora_45941130_id_10046.log
TKPROF: Release 11.2.0.4.0 - Development on 星期四 7月 12 17:13:36 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
$ls -ltr *log
-rw-r----- 1 oracle oinstall 46076 Jul 12 17:13 DB2_ora_45941130_id_10046.log