Event 10046 - Enable SQL Statement Trace

paulyibinyi發表於2008-01-09

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-120040/,如需轉載,請註明出處,否則將追究法律責任。

相關文章