Oracle學習筆記:10046 SQL tracle event

來源:互聯網
上載者:User

10046event可以追蹤記錄orale有關sql執性語句情況。追蹤記錄檔案記錄在user_dump_dest指定的目錄下。

其中有四種level:

  • 1:執行sql語句跟蹤;
  • 4:綁定變數 ;
  • 8:等待事件;
  • 12:綁定變數和等待

     

    開啟事件跟蹤:

    1. 針對所有session,在initsid.ora裡設定-開啟 或 alter system set:event='10046 trace name context forever,level n'  [scope=spfile]  --需要重啟oracle
    2. 針對所有session,在initsid.ora裡設定-關閉 或 alter system set:event=''  [scope=spfile]  --需要重啟oracle
    3. 針對當前session,開啟:alter session set events='10046 trace name context forever,level n'  --立即生效
    4. 針對當前session,關閉:alter session set events='10046 trace name context off'  --立即生效
    5. 針對其他session,如何跟蹤:

    step1:確定要跟蹤的pid(oracle的processid) 或 spid(os的進程pid):

    SELECT a.sid, a.serial#, b.spid, b.pid, a.username, a.osuser, a.machine 

    FROM v$session a, v$process b

    WHERE a.username IS NOT NULL AND a.paddr=b.addr;

    step2:以sysdba的身份登陸sqlplus

    step3:初始化跟蹤,oradebug setpid pid_n | oradebug setospid spid_n

      step4:開啟跟蹤,oradebug event 10046 trace name context forever,lever n

      step5:關閉跟蹤,oradebug event 10046 trace name context off

      其他:oradebu還可以設定追蹤檔案的fullpathname,oradebug tracefile_name filepec

        6.使用dbms_system

      Dbms_system.set_ev (
      si binary_integer, -- SID
      se binary_integer, -- Serial#
      ev binary_integer, -- Event code or number to set.
      le binary_integer, -- Usually level to trace
      cm binary_integer -- When to trigger (NULL = context forever.)
       
      To enable 10046 level 12 tracing for SID 22 with a serial# of 99 we would execute the set_ev procedure as shown here:
      Exec dbms_system.set_ev(12,22,10046,12,’’);
      To disable 10046 tracing enter the following:
      Exec dbms_system.set_ev(12,22,10046,0,’’);

      相關文章

      聯繫我們

      該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

      如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

      A Free Trial That Lets You Build Big!

      Start building with 50+ products and up to 12 months usage for Elastic Compute Service

      • Sales Support

        1 on 1 presale consultation

      • After-Sales Support

        24/7 Technical Support 6 Free Tickets per Quarter Faster Response

      • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.