首页 > 代码库 > 使用DBMS_SUPPORT包
使用DBMS_SUPPORT包
DBMS_SUPPORT包从Oracle7.2引入,主要功能用以提供更完整的用户session跟踪信息,这个包可以通过运行 dbmssupp.sql 和 prvtsupp.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 SQL> select dbms_support.PACKAGE_VERSION from dual; PACKAGE_VERSION |
4.进程跟踪(跟踪当前session及其他session)
SQL> exec dbms_support.start_trace PL/SQL procedure successfully completed. SQL> select count(*) from dba_users; COUNT(*) SQL> exec dbms_support.stop_trace; PL/SQL procedure successfully completed. SQL> select sid,serial#,username from v$session SID SERIAL# USERNAME 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 |
使用DBMS_SUPPORT包