使用sys.dbms_system.ksdwrt存储过程可以实现主动向alert或trace文件中记录信息的功能。简单记录一下,供参考。
1.先看一下向alert文件中写信息的功能
1)使用参数“2”实现向alert文件中记录信息
sys@ora10g> execute sys.dbms_system.ksdwrt(2,'Secooler marked here at '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
PL/SQL procedure successfully completed.
2)查看alert文件,会发现如下两条信息,第一条是系统自动记录的时间,第二条就是我悄悄做的mark。
Thu Dec 17 21:24:41 2009
Secooler marked here at 2009-12-17 21:24:41
2.再看一下向trace文件中写信息的功能
1)使用参数“1”实现向trace文件中记录信息
sys@ora10g> execute sys.dbms_system.ksdwrt(1,'Secooler marked here at '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
PL/SQL procedure successfully completed.
2)此时会自动创建一个trace文件,并在trace文件中看到我们写入的信息。
sys@ora10g> ed /oracle/app/oracle/admin/ora10g/udump/ora10g_ora_3634.trc
/oracle/app/oracle/admin/ora10g/udump/ora10g_ora_3634.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
ORACLE_HOME = /oracle/app/oracle/product/10.2.0/db_1
System name: Linux
Node name: asdlabdb01
Release: 2.6.18-128.el5
Version: #1 SMP Wed Dec 17 11:41:38 EST 2008
Machine: x86_64
Instance name: ora10g
Redo thread mounted by this instance: 1
Oracle process number: 14
Unix process pid: 3634, image: oracle@asdlabdb01 (TNS V1-V3)
*** 2009-12-17 21:28:51.050
*** SERVICE NAME:(SYS$USERS) 2009-12-17 21:28:51.050
*** SESSION ID:(513.163) 2009-12-17 21:28:51.050
Secooler marked here at 2009-12-17 21:28:51
~
~
3.该存储过程可以同时向alert文件和trace文件写入信息
1)使用参数“3”便可以实现同时向alert和trace文件中记录信息
sys@ora10g> execute sys.dbms_system.ksdwrt(3,'Secooler marked here at '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));
PL/SQL procedure successfully completed.
2)查看在alert文件中记录的信息
Thu Dec 17 21:30:08 2009
Secooler marked here at 2009-12-17 21:30:08
3)查看在trace文件中记录的信息
*** 2009-12-17 21:30:08.067
Secooler marked here at 2009-12-17 21:30:08
4.小结
如果对系统的某系紧急事件需要向alert或trace文件输出的话,这是一个很好的途径。
sys.dbms_system.ksdwrt存储过程中DEST有三个可用值:
PROCEDURE KSDWRT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DEST BINARY_INTEGER IN
TST VARCHAR2 IN
“1”:向trace文件中写入信息;
“2”:向alert文件中写入信息:
“3”:同时向trace和alert文件中写入信息。
Good luck.
secooler
09.12.17
-- The End --
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70034820/viewspace-2994333/
,如需转载,请注明出处,否则将追究法律责任。