https://www.cnblogs.com/ss-33/p/10109383.html

格式:alter system|session set events ‘[eventnumber|immediate] trace name eventname [forever] [, level levelnumber] : „„.’
通过“:”符号,可以连续设置多个事件,也可以通过连续使用alter session set events来设置多个事件。
格式说明: eventnumber指触发dump的事件号,事件号可以是Oracle错误号(出现相应错误时跟踪指定的事件)或oralce内部事件号,
内部事件号在10000到10999之间,不能与immediate关键字同用。 immediate关键字表示命令发出后,立即将指定的结构
dump到跟踪文件中,这个关键字只用在alter session语句中,并且不能与eventnumber、forever关键字同用。
trace name是关键字 eventname指事件名称(见后面),即要进行dump的实际结构名。若eventname为context,则指根据内部事件号进行跟踪。
forever关键字表示事件在实例或会话的周期内保持有效状态,不能与immediate同用。
level为事件级别关键字。但在dump错误栈(errorstack)时不存在级别。 levelnumber表示事件级别号,一般从1到10,1表示只dump结构头部信息,10表示dump结构的所有信息

一.Memory Dumps

1).Global Area

ALTER SESSION SET EVENTS ‘immediate trace name global_area level n’;

1 包含PGA
2 包含SGA
4 包含UGA
8 包含indrect memory

2).Library Cache

ALTER SESSION SET EVENTS ‘immediate trace name library_cache level n’;

1 library cache统计信息
2 包含hash table histogram
3 包含object handle
4 包含object结构(Heap 0)

3).Row Cache

ALTER SESSION SET EVENTS ‘immediate trace name row_cache level n’;

1 row cache统计信息
2 包含hash table histogram
8 包含object结构

4).Buffers

ALTER SESSION SET EVENTS ‘immediate trace name buffers level n’;

1 buffer header
2 level 1 + block header
3 level 2 + block contents
4 level 1 + hash chain
5 level 2 + hash chain
6 level 3 + hash chain
8 level 4 + users/waiters
9 level 5 + users/waiters
10 level 6 + users/waiters

5).Buffer

ALTER SESSION SET EVENTS ‘immediate trace name buffer level n’;

n为某个指定block的rdba,该命令可以转储某个block在buffer中的所有版本。

6).Heap

ALTER SESSION SET EVENTS ‘immediate trace name heapdump level level’;

1 PGA摘要
2 SGA摘要
4 UGA摘要
8 Current call(CGA)摘要
16 User call(CGA)摘要
32 Large call(LGA)摘要
1025 PGA内容
2050 SGA内容
4100 UGA内容
8200 Current call内容
16400 User call内容
32800 Large call内容

7).Sub Heap

Oracle 9.0.1版本之前

ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level n’;

若n为subheap的地址,转储的是subheap的摘要信息
若n为subheap的地址+1,转储的则是subheap的内容

Oracle 9.2.0版本之后

ALTER SESSION SET EVENTS ‘immediate trace name heapdump_addr level n, addr m’;

其中m为subheap的地址

n为1转储subheap的摘要,n为2转储subheap的内容

8).Process State

ALTER SESSION SET EVENTS ‘immediate trace name processstate level n’;

9).System State

ALTER SESSION SET EVENTS ‘immediate trace name systemstate level n’;

10).Error State

ALTER SESSION SET EVENTS ‘immediate trace name errorstack level n’;

0 Error stack
1 level 0 + function call stack
2 level 1 + process state
3 level 2 + context area

11).Hang Analysis

ALTER SESSION SET EVENTS ‘immediate trace name hanganalyze level n’;

12).Work Area

ALTER SESSION SET EVENTS ‘immediate trace name workareatab_dump level n’;

1 SGA信息
2 Workarea Table摘要信息
3 Workarea Table详细信息

13).Latches

ALTER SESSION SET EVENTS ‘immediate trace name latches level n’;

1 latch信息
2 统计信息

14).Events

ALTER SESSION SET EVENTS ‘immediate trace name events level n’;

1 session
2 process
3 system

15).Locks

ALTER SESSION SET EVENTS ‘immediate trace name locks level n’;

16).Shared Process

ALTER SESSION SET EVENTS ‘immediate trace name shared_server_state level n’;

n取值为1~14

17).Background Messages

ALTER SESSION SET EVENTS ‘immediate trace name bg_messages level n’;

n为pid+1

二.File Dumps

1).Block

Oracle 7之前

ALTER SESSION SET EVENTS ‘immediate trace name blockdump level n’;

n为block的rdba

Oracle8以后

ALTER SYSTEM DUMP DATAFILE file# BLOCK block#;

ALTER SYSTEM DUMP DATAFILE file#
BLOCK MIN minimum_block#
BLOCK MAX maximum_block#;

2).Tree Dump

ALTER SESSION SET EVENTS ‘immediate trace name treedump level n’;

n为object_id

3).Undo Segment Header

ALTER SYSTEM DUMP UNDO_HEADER ‘segment_name’;

4).Undo for a Transaction

ALTER SYSTEM DUMP UNDO BLOCK ‘segment_name’ XID xidusn xidslot xidsqn;

5).File Header

ALTER SESSION SET EVENTS ‘immediate trace name file_hdrs level n’;

1 控制文件中的文件头信息
2 level 1 + 文件头信息
3 level 2 + 数据文件头信息
10 level 3

6).Control file

ALTER SESSION SET EVENTS ‘immediate trace name controlf level n’;

1 文件头信息
2 level 1 + 信息 + 检查点信息
3 level 2 + 可重用节信息
10 level 3

7).Redo log Header

ALTER SESSION SET EVENTS ‘immediate trace name redohdr level n’;

1 控制文件中的redo log信息
2 level 1 + 文件头信息
3 level 2 + 日志文件头信息
10 level 3

8).Redo log

ALTER SYSTEM DUMP LOGFILE ‘FileName’;

ALTER SYSTEM DUMP LOGFILE ‘FileName’
SCN MIN MinimumSCN
SCN MAX MaximumSCN
TIME MIN MinimumTime
TIME MAX MaximumTime
LAYER Layer
OPCODE Opcode
DBA MIN FileNumber . BlockNumber
DBA MAX FileNumber . BlockNumber
RBA MIN LogFileSequenceNumber . BlockNumber
RBA MAX LogFileSequenceNumber . BlockNumber;

其中time = (((((yyyy - 1988)) * 12 + mm - 1) * 31 + dd - 1) * 24 + hh) * 60 + mi)* 60 + ss;

9).Loghist

ALTER SESSION SET EVENTS ‘immediate trace name loghist level n’;

1dump控制文件中最早和最迟的日志历史项

1 dump 2^n个日志历史项

Introduction
There are four types of numeric events

Immediate dumps
Conditional dumps
Trace dumps
Events that change database behaviour
Every event has a number which is in the Oracle error message range e.g. event 10046 is ORA-10046

Each event has one or more levels which can be

range e.g. 1 to 10
bitmask e.g. 0x01 0x02 0x04 0x08 0x10
flag e.g. 0=off; 1=on
identifier e.g. object id, memory address etc
Note that events change from one release to another. As existing events become deprecated and then obsolete, the event number is frequently reused for a new event. Note also that the message file sometimes does not reflect the events in the current release.

Many events change the behaviour of the database. Some testing events may cause the database to crash. Never set an event on a production database without obtaining permission from Oracle support. In addition, never set an event on a development database without first making a backup.

Enabling Events
Events can be enabled at instance level in the init.ora file using

event=’ trace name context forever, level ';
Multiple events can be enabled in one of two ways

1 - Use a colon to separate the event text e.g.

event = “10248 trace name context forever, level 10:10249 trace name context forever, level 10”
2 - List events on consecutive lines e.g.

event = “10248 trace name context forever, level 10”
event = “10249 trace name context forever, level 10”
Note that in some versions of Oracle, the keyword “event” must be in the same case (i.e. always uppercase or always lowercase).

Events can also be enabled at instance level using the ALTER SYSTEM command:

ALTER SYSTEM SET EVENTS ’ trace name context forever, level ';
Events are disabled at instance level using:

ALTER SYSTEM SET EVENTS ’ trace name context off’;
In Oracle 11.1 and above a more concise syntax is available:

ALTER SYSTEM SET EVENTS ‘10235’;
ALTER SYSTEM SET EVENTS ‘10235 level 1’;
ALTER SYSTEM SET EVENTS ‘10235 off’;
Events can also be enabled at session level using the ALTER SESSION command:

ALTER SESSION SET EVENTS ’ trace name context forever, level ';
Events are disabled at session level using:

ALTER SESSION SET EVENTS ’ trace name context off’;
In Oracle 11.1 and above a more concise syntax is available:

ALTER SESSION SET EVENTS ‘10235’;
ALTER SESSION SET EVENTS ‘10235 level 1’;
ALTER SESSION SET EVENTS ‘10235 off’;
Events can be enabled in other sessions using ORADEBUG

To enable an event in a process use:

ORADEBUG EVEMT LEVEL
For example

ORADEBUG EVEMT 10053 LEVEL 1
The default level is 1 so the above can be rewritten as:

ORADEBUG EVEMT 10053
To disable trace again:

ORADEBUG EVEMT 10053 OFF
The original syntax still works in Oracle 11g/12c:

To enable an event in a process use:

ORADEBUG EVENT TRACE NAME CONTEXT FOREVER, LEVEL
For example to set event 10046, level 12 in Oracle process 8 use

ORADEBUG SETORAPID 8
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
To disable an event in a process use:

ORADEBUG EVENT TRACE NAME CONTEXT OFF
To enable an event in a session use:

ORADEBUG SESSION_EVENT &;tevent> TRACE NAME CONTEXT FOREVER, LEVEL
For example:

ORADEBUG SESSION_EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
To disable an event in a session use:

ORADEBUG SESSION_EVENT TRACE NAME CONTEXT OFF
For example:

ORADEBUG SESSION_EVENT 10046 TRACE NAME CONTEXT OFF
Events can be also enabled in other sessions using DBMS_SYSTEM.SETEV

The SID and the serial number of the target session must be obtained from V$SESSION.

For example to enable event 10046 level 8 in a session with SID 9 and serial number 29 use:

EXECUTE dbms_system.set_ev (9,29,10046,8,’’);
To disable event 10046 in the same session use

EXECUTE dbms_system.set_ev (9,29,10046,0,’’);
Listing All Events
Most events are numbered in the range 10000 to 10999. To dump all event messages in this range use:

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;
/
On Unix systems event messages are in the formatted text file:

$ORACLE_HOME/rdbms/mesg/oraus.msg
To print detailed event messages (Unix only) use the following script:

event=10000
while [ $event -ne 10999 ]
do
event=expr $event + 1
oerr ora $event
done
Listing Enabled Events
To check which events are enabled in the current session:

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;
/

oracle event   设置 alter system set events相关推荐

  1. alter system|session set events转储

    格式: alter system|session set events '[eventnumber|immediate] trace name eventname [forever] [, level ...

  2. 【Oracle】设置快速恢复区及reset快速恢复区

    快速恢复区 概念 是一个默认放置所有备份恢复操作有关文件的地方,包括:控制文件在线镜像.在线重做日志.归档日志.外来归档日志.控制文件镜像复制.数据文件镜像复制.RMAN备份片和闪回日志. 如果启用的 ...

  3. oracle 10g alter system reset,《深入浅出Oracle》勘误表

    <深入浅出Oracle>勘误表 非常感谢很多朋友不断指出<深入浅出Oracle>一书中的错误之处,我把一些勘误整理在这里,给读者朋友们参考(以下勘误按照发现先后列出,并为按照页 ...

  4. [Oracle]如何在Oracle中设置Event

    为了调查Oracle 的故障,可以通过设置event ,来了解详细的状况.方法如下: ■ 如果使用 SPFILE, ============= To enable it: 1. Check the c ...

  5. Oracle 11g sys,system 密码忘记设置解决办法

    原文: Oracle 11g sys,system 密码忘记设置解决办法 1.启动sqlplus 2.请输入用户名:  sqlplus/as sysdba 3.输入口令: 直接回车 4.连接到: Or ...

  6. alter system flush oracle的缓存

    下面3条语句,旨在刷新oracle的缓存.这里总结一下. 1)alter system flush global context 下图说明: 对于多层架构的,如上图:应用服务器和数据块服务器通过连接池 ...

  7. oracle alter system set,alter system set control_files=..............

    改control_files这个参数的时候,需要注意格式,稍有不慎就会改错. 正确格式如下: SQL>alter system set control_files='E:\app\oracle\ ...

  8. [译] ALTER SYSTEM CANCEL SQL : 在 Oracle Database 18c 的会话中取消 SQL 语句

    原文地址:https://oracle-base.com/articles/18c/alter-system-cancel-sql-18c 原文作者:Tim Hall Oracle Database ...

  9. oracle flush,alter system flush oracle的缓存

    下面3条语句,旨在刷新oracle的缓存.这里总结一下. 1)alter system flush global context 下图说明: 对于多层架构的,如上图:应用服务器和数据块服务器通过连接池 ...

最新文章

  1. 讨论丨深度学习已经成为过去?迁移学习才是真正的未来?
  2. Docker导入导出镜像两种方式
  3. Matlab如何读取文本文件
  4. python教程是什么-Python基础教程_Python入门知识
  5. 开源调度框架xxl-job集成SpringBatch详解
  6. fastdfs java上传文件_FastDFS java客户端文件上传demo
  7. ScaleGestureDetector使用注意事项
  8. 从C语言到C++的进阶之一些C基础上的增强用法(篇五)
  9. windows运行python脚本卡住_运行python脚本安装windows服务时没有响应
  10. sublime中文件前缀的自动添加
  11. Appium desktop下载安装
  12. 中国象棋(单机版)java_中国象棋大师-中国象棋单机版下载 2017最新版-中国象棋单机游戏下载-pc6游戏网...
  13. 华为android怎么打开usb调试,华为PLK-AL10 开启USB调试模式
  14. Android 检查权限总是 PERMISSION_GRANTED
  15. php amp 转义,HTML转义和反转义
  16. 防火墙 蓝精灵DoS P127
  17. php 表格模板,怎么制作excel表格模板
  18. TMOS系统之NATS 和 SNAT
  19. html5之DeviceOrientation 手机重力与方向感应
  20. 201571030112/201571030108 小学四则运算练习软件软件需求说明

热门文章

  1. 全球6G产业及政策进展研究
  2. 物质是世界,能量是本质
  3. ABP VNext学习日记30
  4. 阿里IOT云飞燕平台的使用和感悟。
  5. 感抗和容抗的计算及说明
  6. 恐龙为何不发明计算机,为什么恐龙没有产生智慧文明,而人类文明反而如此发达?...
  7. vue报错:vue.js:634 [Vue warn]: Cannot find element: #app
  8. 多金的ToG项目总结——数字人民币
  9. 《设计模式》之策略模式
  10. 功利主义穆勒思维导图_浅析穆勒的功利主义思想及现实意义