ʹÓÃSQL_TRACE½øÐÐÊý¾Ý¿âÕï¶Ï£¨2£©_SQL SERVERÊý¾Ý¿â_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

ʹÓÃSQL_TRACE½øÐÐÊý¾Ý¿âÕï¶Ï£¨2£©

×÷ÕߣººÚ¿Í·ÀÏßÍø°²SQLά»¤»ùµØ À´Ô´£ººÚ¿Í·ÀÏßÍø°²SQLά»¤»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºÕï¶ÏÊý¾Ý¿â½øÐÐʹÓÃ
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£º    ´ËÉèÖöÔËùÓÐÓû§µÄËùÓнø³ÌÉúЧ¡¢°üÀ¨ºǫ́½ø³Ì.2£® ¶Ôµ±Ç°sessionÉèÖÃͨ¹ýalter sessionµÄ·½Ê½Ð޸ģ¬ÐèÒªalter sessionµÄϵͳȨÏÞ: SQL> alter session set events '10046 trace n...

    ´ËÉèÖöÔËùÓÐÓû§µÄËùÓнø³ÌÉúЧ¡¢°üÀ¨ºǫ́½ø³Ì.

2£® ¶Ôµ±Ç°sessionÉèÖÃ
ͨ¹ýalter sessionµÄ·½Ê½Ð޸ģ¬ÐèÒªalter sessionµÄϵͳȨÏÞ:


 

SQL> alter session set events '10046 trace name context forever';

Session altered.

SQL> alter session set events '10046 trace name context forever, level 8';

Session altered.

SQL> alter session set events '10046 trace name context off';

Session altered.

      

3£® ¶ÔÆäËûÓû§sessionÉèÖÃ
ͨ¹ýDBMS_SYSTEM.SET_EVϵͳ°üÀ´ÊµÏÖ:

 

SQL> desc dbms_system...PROCEDURE SET_EV Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- SI BINARY_INTEGER IN SE BINARY_INTEGER IN EV BINARY_INTEGER IN LE BINARY_INTEGER IN NM VARCHAR2 IN... 

 

¡¡¡¡

ÆäÖеIJÎÊýSI¡¢SEÀ´×Ôv$sessionÊÓͼ:

      

      ²éѯ»ñµÃÐèÒª¸ú×ÙµÄsessionÐÅÏ¢:
        SQL> select sid,serial#,username from v$session where username is not null;SID SERIAL# USERNAME
---------- ---------- ------------------------------
8 2041 SYS
9 437 EYGLE


Ö´Ðиú×Ù:
SQL> exec dbms_system.set_ev(9,437,10046,8,'eygle');

PL/SQL procedure successfully completed.

½áÊø¸ú×Ù:
SQL> exec dbms_system.set_ev(9,437,10046,0,'eygle');

PL/SQL procedure successfully completed.

 


(c) »ñÈ¡¸ú×ÙÎļþ
ÒÔÉÏÉú³ÉµÄ¸ú×ÙÎļþλÓÚuser_dump_destĿ¼ÖУ¬Î»Öü°ÎļþÃû¿ÉÒÔͨ¹ýÒÔÏÂSQL²éѯ»ñµÃ:


      

      SQL> select
          2    d.value||'/'||lower(rtrim(i.instance, chr(0)))||'_ora_'||p.spid||'.trc' trace_file_name
          3  from
          4    ( select p.spid
          5      from sys.v$mystat m,sys.v$session s,sys.v$process p
          6      where m.statistic# = 1 and s.sid = m.sid and p.addr = s.paddr) p,
          7    ( select t.instance from sys.v$thread  t,sys.v$parameter  v
          8      where v.name = 'thread' and (v.value = 0 or t.thread# = to_number(v.value))) i,
          9    ( select value from sys.v$parameter where name = 'user_dump_dest') d
         10  /

TRACE_FILE_NAME
--------------------------------------------------------------------------------
/opt/oracle/admin/hsjf/udump/hsjf_ora_1026.trc


 
                        

 

(d) ¶ÁÈ¡µ±Ç°sessionÉèÖõIJÎÊý
µ±ÎÒÃÇͨ¹ýalter sessionµÄ·½Ê½ÉèÖÃÁËsql_trace,Õâ¸öÉèÖÃÊDz»ÄÜͨ¹ýshow parameterµÄ·½Ê½µÃµ½µÄ,ÎÒÃÇÐèҪͨ¹ýdbms_system.read_evÀ´»ñÈ¡£º


      

      SQL> set feedback off
        SQL> set serveroutput on SQL> declare
2 event_level number;
3 begin
4 for event_number in 10000..10999 loop
5 sys.dbms_system.read_ev(event_number, event_level);
6 if (event_level > 0) then
7 sys.dbms_output.put_line(
8 'Event ' ||
9 to_char(event_number) ||
10 ' is set at level ' ||
11 to_char(event_level)
12 );
13 end if;
14 end loop;
15 end;
16 /
Event 10046 is set at level 1
 

 

    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-11050-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2012-03-21 03:14:21  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer