eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« 如何启用sqlplus的AutoTrace功能 | Blog首页 | 关于checkpoint cnt和checkpoint scn »

使用DBMS_SUPPORT包
modb.pro

DBMS_SUPPORT包从Oracle7.2引入,主要功能用以提供更完整的用户session跟踪信息

这个包可以通过运行 dbmssupp.sqlprvtsupp.plb 两个脚本来创建.

该脚本位于$ORACLE_HOME/rdbms/admin目录下

以下版本中都包含这些文件:

8.0.6, 8.1.7, 9.0.1, 9.2.0 and above

1.创建DBMS_SUPPORT Package

 

SQL> @?/rdbms/admin/dbmssupp.sql

Package created.

Package body created.

SQL> @?/rdbms/admin/prvtsupp.plb

Package body created.

 

2.主要函数及过程

 

SQL> desc dbms_support

FUNCTION MYSID RETURNS NUMBER

FUNCTION PACKAGE_VERSION RETURNS VARCHAR2

PROCEDURE START_TRACE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 WAITS                          BOOLEAN                 IN     DEFAULT
 BINDS                          BOOLEAN                 IN     DEFAULT

PROCEDURE START_TRACE_IN_SESSION
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SID                            NUMBER                  IN
 SERIAL                         NUMBER                  IN
 WAITS                          BOOLEAN                 IN     DEFAULT
 BINDS                          BOOLEAN                 IN     DEFAULT

PROCEDURE STOP_TRACE

PROCEDURE STOP_TRACE_IN_SESSION
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 SID                            NUMBER                  IN
 SERIAL                         NUMBER                  IN
  


3.简单用法

 

 

SQL> SELECT DBMS_SUPPORT.MYSID from DUAL;

MYSID
----------
8

SQL> select dbms_support.PACKAGE_VERSION from dual;

PACKAGE_VERSION
--------------------------------------------------------------------------------
DBMS_SUPPORT Version 1.0 (17-Aug-1998) - Requires Oracle 7.2 - 8.0.5

 


4.进程跟踪(跟踪当前session及其他session)

 

 

SQL> exec dbms_support.start_trace

PL/SQL procedure successfully completed.

SQL> select count(*) from dba_users;

COUNT(*)
----------
34

SQL> exec dbms_support.stop_trace;

PL/SQL procedure successfully completed.

SQL> select sid,serial#,username from v$session
2 /

SID SERIAL# USERNAME
---------- ---------- ------------------------------
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 764 SYS

8 rows selected.

SQL> exec dbms_support.start_trace_in_session(4,1);

PL/SQL procedure successfully completed.

SQL> exec dbms_support.stop_trace_in_session(4,1);

PL/SQL procedure successfully completed.


5.Trace文件

以上跟踪生成的Trace文件可以在udump目录下找到.

 

SQL> show parameter user_dump

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string /opt/oracle/admin/hsjf/udump

 

 


历史上的今天...
    >> 2013-06-19文章:
    >> 2011-06-19文章:
           父亲节的礼物
    >> 2010-06-19文章:
    >> 2007-06-19文章:
    >> 2006-06-19文章:

By eygle on 2004-06-19 21:20 | Comments (0) | SQL.PLSQL | 13 |


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com