Event 10046 – Enable SQL Statement Trace
Event 10046 - Enable SQL Statement Trace
This event can be used to dump SQL statements executed by a session with execution plans and statistics. Bind variable and wait statistics can optionally be included. Level 12 is the most detailed.
For example
1.使用触发器
create or replace trigger logon_trigger
after logon on database
begin
if (user='PAUL') then
execute immediate
'alter session set events ''10046 trace name context forever,level 12''';
end if;
end;
2.直接在sqlplus下使用命令
ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';
关闭10046事件用以下命令:
alter session set events’10046 trace name context off’;
Level Action
1 Print SQL statements, execution plans and execution statistics
4 As level 1 plus bind variables
8 As level 1 plus wait statistics
12 As level 1 plus bind variables and wait statistics