前面已经解释了events的含义、分类等信息,那么在oracle中到底有多少events呢?
下面我就来解释一下这个问题。
oracle每个版本中所拥有的events可能是不一样的,甚至是同一个event在不同的版本中所包含的含义和功能也是不一样的,这点是需要注意的。
很多event会改变oracle的行为,在前面的分类中我已经做过这类event的含义解释了,有些event甚至会导致数据库crash,因此在使用event的使用要特别小心。在没有oracle support明确允许和支持下,不要在生产库中设置使用event;在使用event之前,必须要对库做一个备份。
如何列出所有的events?
大部分的event number是介于10000与10999之间,因此你可以使用如下的plsql脚本来列出所有的脚本名称:
SET SERVEROUTPUT ON DECLARE err_msg VARCHAR2(120); BEGIN dbms_output.enable (1000000); FOR err_num IN 10000..10999 LOOP err_msg := SQLERRM (-err_num); IF err_msg NOT LIKE \'%Message \'||err_num||\' not found%\' THEN dbms_output.put_line (err_msg); END IF; END LOOP; END; /
另外在unix或者类unix系统中,oracle已经提供了一个经过格式化的文本,里面列出了所有的event(当然就包括错误列表了),它是:
$ORACLE_HOME/rdbms/mesg/oraus.msg
上面只是简单的列出了所有的events,在unix系统中,如果你想列出每个events的所有信息,如每个level的含义啊,第一种方法当然就是查上面给出的那个文本文件,第二种方法,可以使用以下的脚本列出:
#!/bin/bashevent=10000 while [ $event -ne 10999 ] do event=`expr $event + 1` oerr ora $event done
将其保存成一个脚本然后运行。
如何检查当前session中已经被启用的events?可使用如下脚本:
SET SERVEROUTPUT ON DECLARE l_level NUMBER; BEGIN FOR l_event IN 10000..10999 LOOP dbms_system.read_ev (l_event,l_level); IF l_level > 0 THEN dbms_output.put_line (\'Event \'||TO_CHAR (l_event)|| \' is set at level \'||TO_CHAR (l_level)); END IF; END LOOP; END; /
常见的events有哪些?
10013 - Monitor Transaction Recovery 10015 - Dump Undo Segment Headers 10032 - Dump Sort Statistics 10033 - Dump Sort Intermediate Run Statistics 10045 - Trace Free List Management Operations 10046 - Enable SQL Statement Trace 10053 - Dump Optimizer Decisions 10060 - Dump Predicates 10065 - Restrict Library Cache Output for State Object Dumps 10079 - Dump SQL*Net Statistics 10081 - Dump High Water Mark Changes 10104 - Dump Hash Join Statistics 10128 - Dump Partition Pruning Information 10200 - Dump Consistent Reads 10201 - Dump Consistent Read Undo Application 10220 - Dump Changes to Undo Header 10221 - Dump Undo Changes 10224 - Dump Index Block Splits / Deletes 10225 - Dump Changes to Dictionary Managed Extents 10241 - Dump Remote SQL Execution 10246 - Trace PMON Process 10248 - Trace Dispatcher Processes 10249 - Trace Shared Server (MTS) Processes 10270 - Debug Shared Cursors 10357 - Debug Direct Path 10390 - Dump Parallel Execution Slave Statistics 10391 - Dump Parallel Execution Granule Allocation 10393 - Dump Parallel Execution Statistics 10500 - Trace SMON Process 10608 - Trace Bitmap Index Creation 10704 - Trace Enqueues 10706 - Trace Global Enqueue Manipulation 10708 - Trace RAC Buffer Cache 10710 - Trace Bitmap Index Access 10711 - Trace Bitmap Index Merge Operation 10712 - Trace Bitmap Index OR Operation 10713 - Trace Bitmap Index AND Operation 10714 - Trace Bitmap Index MINUS Operation 10715 - Trace Bitmap Index Conversion to ROWIDs 10716 - Trace Bitmap Index Compress / Decompress 10717 - Trace Bitmap Index Compaction 10719 - Trace Bitmap Index DML 10730 - Trace Fine Grained Access Predicates 10731 - Trace CURSOR Statements 10928 - Trace PL/SQL Execution 10938 - Trace PL/SQL Execution Statistics