在PL/SQL代码中或SQL*Plus命令行中均可以使用“SYS.DBMS_SYSTEM.KSDWRT”来实现向Oracle警告日志中写入信息的目的。1.进入到alert目录存放位置ora10g@asdlabdb01 /home/oracle$ cd $ORACLE_BASE/admin/$ORACLE_SID/bdump
2.查看警告日志中最后10行的信息
ora10g@asdlabdb01 /oracle/app/oracle/admin/ora10g/bdump$ tail -10 alert_ora10g.log
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=32, OS id=31597
Thu Dec 15 06:23:57 2010
Completed: ALTER DATABASE OPEN
Thu Dec 15 06:23:57 2010
db_recovery_file_dest_size of 4096 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
此处是为了对比写入前后信息的不同。
3.在SQL*Plus中实现向alert日志中写入信息的目的
ora10g@asdlabdb01 /oracle/app/oracle/admin/ora10g/bdump$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Thu Dec 15 06:24:33 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
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
sys@ora10g> exec SYS.DBMS_SYSTEM.KSDWRT(2, 'Alert message writed by Secooler.');
PL/SQL procedure successfully completed.
sys@ora10g> exit
Disconnected from 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
4.查看alert日志中写入的内容
ora10g@asdlabdb01 /oracle/app/oracle/admin/ora10g/bdump$ tail -10 alert_ora10g.log
QMNC started with pid=32, OS id=31597
Thu Dec 15 06:23:57 2010
Completed: ALTER DATABASE OPEN
Thu Dec 15 06:23:57 2010
db_recovery_file_dest_size of 4096 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Thu Dec 15 06:24:39 2010
Alert message writed by Secooler.
可见alert日志中的最后两行记录了这条写入的信息(第一行表示写入的时间,第二行便是写入信息的内容)。
--转自