Oracle Undo

来源:互联网 发布:sql server offset 编辑:程序博客网 时间:2024/05/02 00:03

UNDO表空间用于存放UNDO数据,当执行DML操作(insert、update、delete)的时候,oracle会将这些操作的旧数据写入到UNDO段。

 

UNDO数据也称为回滚数据,用于确保数据的一致性。作用包括:

1、回退事务

2、读一致性

3、事务恢复

4、闪回查询

 

 

 

 

9i开始,管理UNDO数据可以使用UNDO表空间,也可以使用回滚段。10g开始,oracle已经放弃使用回滚段。

 

用于undo管理的参数:

1、UNDO_MANAGEMENT

用于指定undo数据的管理方式。如果使用自动管理,必须设置为AUTO;如果手动管理,必须设置为MANUAL。

使用自动管理的时候,oracle会使用UNDO表空间管理UNDO数据;使用手动管理时,oracle会使用回滚段管理UNDO数据。

如果使用自动管理模式,必须建立UNDO表空间,并且配置UNDO_TABLESPACE参数,否则oracle会使用SYSTEM回滚段存放UNDO纪录,并在警告日志中纪录提示。

 

2、UNDO_TABLESPACE

用于指定例程所要使用的UNDO表空间。设置的时候,必须保证该表空间存在,否则会导致例程启动失败。

使用RAC的时候,因为一个UNDO不能由多个例程同时使用,所以必须为每个例程配置一个独立的UNDO表空间。

 

3、UNDO_RETENTION

用于控制UNDO数据的最大保留时间,其默认值为900秒。从9i开始,通过配置该初始化参数,可以指定UNDO数据的保留时间,从而确定闪回查询可以查看到的最早时间点。

 

建立UNDO表空间

1、使用CREATE DATABASE命令建立UNDO表空间

如果使用的是UNDO管理模式,但是没有指定UNDOTABLESPACE,那么建立数据库的时候oracle会自动生成名称为SYS_UNDOTBS的UNDO表空间。

 

2、使用CREATE UNDO TABLESPACE 命令建立UNDO表空间

建立数据库以后,可以使用该命令建立UNDO表空间。

 

修改UNDO表空间

当事务用尽UNDO表空间后,增加数据文件:

ALTER TABLESPACE ... ADD DATAFILE;

 

当UNDO表空间所在磁盘填满时,移动数据文件到其他磁盘:

ALTER TABLESPACE ...RENAME DATAFILE;

 

当在OPEN状态下移动UNDO表空间时,可以使表空间脱机/联机:

ALTER TABLESPACE ... OFFLINE/ONLINE;

 

当数据库处于归档模式时,备份UNDO表空间:

ALTER TABLESPACE ... BEGIN BACKUP/END BACKUP

 

切换UNDO表空间

启动并打开oracle数据库后,同一时刻只能使用一个UNDO表空间。可以切换UNDO表空间:

ALTER SYSTEM SET undo_tablespace=undotbs02;

 

删除UNDO表空间

当前使用的UNDO表空间不能被删除,如果要删除当前实例使用的UNDO,需要先切换,然后删除:

DROP TABLESPACE undotbs01;

 

监控UNDO表空间的使用:

1、确定当前正在使用的undo表空间:

show parameter undo_tablespace

NAME                                TYPE   VALUE                                

--------------------------------------------------------------------  ------------------------------       

undo_tablespace                     string   UNDOTBS1       

                          

2、显示数据库的所有UNDO表空间:

SQL> select tablespace_name from dba_tablespaceswhere contents='UNDO';

 

TABLESPACE_NAME

------------------------------

UNDOTBS1

 

3、显示UNDO表空间统计信息:

SQL> select to_char(begin_time,'hh24:mi:ss')begin_time,to_char(end_time,'hh24:mi:ss') end_time,undoblks fromv$undostat where rownum < 4;

BEGIN_TIME                                                                 END_TIME UNDOBLKS

----------------------------------------------------------------------------------------------------------------------------------------------------------------

14:52:52                                                                   14:54:56 1

14:42:52                                                                   14:52:52 61

14:32:52                                                                   14:42:52 27

 

4、显示UNDO段统计信息:

使用自动管理模式时,oracle会在UNDO表空间上自动建立10个UNDO段。通过查询动态性能视图V$ROLLNAME,可以显示所有联机UNDO的名称;通过查询动态性能视图V$ROLLSTAT可以显示UNDO段的统计信息。

SQL> select a.name,b.xacts,b.writes,b.extentsfrom v$rollname a,v$rollstat b where a.usn = b.usn;

 

NAME                               XACTS    WRITES   EXTENTS

------------------------------ ---------- --------------------

SYSTEM                                    176730         6

_SYSSMU1$                              524055286         6

_SYSSMU2$                              555250470         3

_SYSSMU3$                              01477369722         6

_SYSSMU4$                              281773370         5

_SYSSMU5$                              149888652         2

_SYSSMU6$                              101947936         2

_SYSSMU7$                              158121686         2

_SYSSMU8$                              203385052         3

_SYSSMU9$                               84385448         3

_SYSSMU10$                             426643090         4

 

xacts用于标示undo段所包含的活动事务个数,writes用于标示undo段上所写入的字节数,extents用于标示undo段的区个数。

 

5、显示活动事务信息:

SQL> select a.username,b.name,c.used_ublk fromv$session a,v$rollname b,v$transaction c where a.saddr=c.ses_addrand b.usn = c.xidusn;

 

6、显示UNDO区信息:

SQL> select extent_id,bytes,status fromdba_undo_extents where segment_name='_SYSSMU10$';

 

 EXTENT_ID     BYTES STATUS

---------- ---------- ---------

            65536 UNEXPIRED

            65536 UNEXPIRED

           1048576EXPIRED

           1048576UNEXPIRED

-------------------------------------------------------------------------------------

在开始之前,我们先来思考几个问题?

1.ora-01555错误的是怎么产生的?有什么办法解决?

该问题,参考我的BlogOracleORA-01555快照过旧

http://blog.csdn.net/tianlesoftware/archive/2009/10/31/4745898.aspx

2.回滚段(回滚表空间)有什么作用?

3.数据库启动的时候,如何加载回滚段(回滚段表空间)。

4.回滚段的数量由什么公式来计算

5.回滚表空间的大小如何确定?


.什么是undo
Oracle数据库在回退、撤销或者改变数据所需要的维护数据库信息的一种手段。这里的数据库信息是指在数据库提交之前的记录的改变等事务信息。


Undo信息主要有以下用途:
当系统发出rollback信息
数据库恢复
提供读一致性


当系统发出rollback命令时,undo信息通过记录的信息将数据库的改变恢复到commit之前的状态。在数据库恢复期间,undo信息被用来从redolog中撤销任何未提交到数据文件的事务。当一个用户在访问数据时,Undo记录通过维护访问数据的前镜像数据来保证当有其他用户改变相同数据时数据库的读一致性。


以前数据库使用回滚段来存储undo信息,这种回滚段管理方式非常的复杂。现在数据库采用undo的方式降低了管理的复杂性,同时减少了dba的工作负荷。但是在数据库只能使用这两种方式的一种。可以在数据库里定义两种方式的文件,但是,同一时刻,必须指定数据使用哪一种方式。当你需要在两种方式中切换时,必须将系统重新启动


Oracle数据库一直使用系统回滚段来完成系统的事务。系统回滚段是在数据库,创建的时候产生的,系统启动后就一直在线。Dba不需要对它作任何的操作来优化。


.指定Undo的方式
oracle9i以后有个初始化参数:undo_management。当将undo_management设置成AUTO时系统使用重做表空间来管理回滚段,当它被设置成MENUAL时系统使用回滚段
oracle推荐使用重做表空间代替回滚段。


当系统使用auto方式管理undo信息时,系统必须指定一个undo表空间。这个表空间可以是在数据库创建时产生,也可以数据库创建后再创建。

当实例启动的时候,系统自动选择第一个有效的undo表空间或者是rollbacksegment,如果没有有效的可用的undo表空间或者是回滚段,系统使用systemrollbacksegment。这种情况是不被推荐的,当系统运行在没有undo的情况下,系统会在alert.log中记录一条警告信息

2.1自动管理模式(AutomaticUndoManagement)


如果系统使用要使用auto方式管理undo信息,那么需要通过指定初始化参数undo_tablespace的值来指定系统使用哪一个undo表空间来存放undo信息。如果指定了undo_tablespace的值,但是系统中不存在这样的表空间,那些系统启动将会失败。此时可以做的操作是,如果系统存在undo表空间,为undo_tablespace指定正确的undo表空间名字,或者将undo_tablespace注释。系统会采用存在的undo表空间。否则使用手动方式。


相关的初始化参数:
undo_tablespace指名系统使用哪一个重做表空间。
undo_suppress_errors被设置成true时表示系统创建和使用回滚段时忽略错误。
undo_retention系统提交后,回滚段的数据保留多长时间,单位是秒
当系统被设置成menual后,这几个参数被忽略。

SQL>showparameterundo

NAMETYPEVALUE

--------------------------------------------------------------

undo_managementstringAUTO

undo_retentioninteger1000

undo_tablespacestringUNDOTBS1

补充:初始化参数UNDO_RETENTION

该参数用来指定undo记录保存的最长时间,以秒为单位,是个动态参数,完全可以在实例运行时随时修改通常默认是900秒,也就是15分钟。

一定要注意,undo_retention只是指定undo数据的过期时间,并不是说,undo中的数据一定会在undo表空间中保存15分钟,比如说刚一个新事务开始的时候,如果undo表空间已经被写满,则新事务的数据会自动覆盖已提交事务的数据,而不管这些数据是否已过期,因此呢,这就又关联回了第一点,当你创建

一个自动管理的undo表空间时,还要注意其空间大小,要尽可能保证undo表空间有足够的存储空间。

同时还要注意,也并不是说,undo_retention中指定的时间一过,已经提交事务中的数据就立刻无法访问,它只是失效,只要不被别的事务覆盖,它会仍然存在,并可随时被flashback特性引用。如果你的undo表空间足够大,而数据库又不是那么繁忙,那么其实undo_retention参数的值并不会影响到你,哪怕你设置成1,只要没有事务去覆盖undo数据,它就会持续有效。因此呢,这里还是那句话,要注意undo表空间的大小,保证其有足够的存储空间。

只有在一种情况下,undo表空间能够确保undo中的数据在undo_retention指定时间过期前一定有效,就是为undo表空间指定RetentionGuarantee,指定之后,oracle对于undo表空间中未过期的undo数据不会覆盖,

例如:

SQL>Altertablespaceundotbs1retentionguarantee;

如果想禁止undo表空间retentionguarantee

例如:

SQL>Altertablespaceundotbs1retentionnoguarantee;


2.2manual管理模式
当将系统中初始化参数undo_management设置成manual后,系统启动后使用rollbacksegment方式存储undo信息。如果系统没有指定undo_management,那么系统默认以manual方式启动,即使设置了auto方式的参数,这些参数将被忽略。


当实例启动时,系统根据如下几个步骤确认onlinerollbacksegment的数量
初始化参数rollback_segments
初始化参数transactionstransactions_per_rollback_segment
menual相关的初始化参数
rollback_segments指定实例启动时所需要的回滚段
transactions指定系统中最大的并发事务数
transactions_per_rollback_segment指定每一个回滚段支持的并发数
max_rollback_segments指明系统支持的最大的online的回滚段数目


.管理undotablespace

创建undotalespace有两种方式:
1.数据库创建时创建undotablespace;
2.在一个已经存在的数据库创建。
undotablespace中不能创建数据库对象,这是因为这个表空间是为数据库recover而准备的。


3.1创建数据库时创建undotablespace
在创建数据库的时候可以通过指定undo子句来创建undotablespace,但是这个子句不是必须的。

如果在创建数据库时,系统指定是auto模式,但是没有指明undotablespace的名字,那么系统会创建一个默认的回滚表空间,名称叫sys_undotbs。这个表空间根据oracle定义的缺省值创建。初始化大小是10m,可以自动扩展。不过oracle推荐最好还是使用一个指定的大小。


CREATEDATABASErbdb1
CONTROLFILEREUSE
...
UNDOTABLESPACEundotbs_01DATAFILE'/u01/oracle/rbdb1/undo0101.dbf';


注意:如果此时系统创建undo失败,那么整个创建数据库的命令就失败了。此时
Dba需要删除已经创建的数据文件,纠正错误,重建创建数据库。


使用createundotablespace子句创建
CREATEUNDOTABLESPACEundotbs_02
DATAFILE'/u01/oracle/rbdb1/undo0201.dbf'SIZE2MREUSE
AUTOEXTENDON;



3.2Undotablespace相关操作


1.增加数据文件
ALTERTABLESPACEundotbs_01
ADDDATAFILE'/u01/oracle/rbdb1/undo0102.dbf'AUTOEXTENDONNEXT1MMAXSIZEUNLIMITED;

2.重命名数据文件

ALTERTABLESPACEundotbs_01RENAMEDATAFILE'/u01/oracle/rbdb1/undo0102.dbf'TO'/u01/oracle/rbdb1/undo0101.dbf';

3.使数据文件online或者offline
ALTERTABLESPACEundotbs_01online|offline;

4.开始或者结束一个联机备份
ALTERTABLESPACEundotbs_01BEGIN|ENDBACKUP;

5.删除undotablespace
Droptablespaceundotbs_01;

Dropundo表空间的时候必须是在未使用的情况下才能进行。如果undo表空间正在使用(例如事务失败,但是还没有恢复成功),那么drop表空间命令将失败。drop表空间的时候可以使用includingcontents


6.切换undotablespace
切换undo表空间有两种方式:

1.使用命令动态修改;

2.修改初始化参数后重新启动数据库。

Altersystemsetundo_tablespace=undotbs1;

当切换命令完成后,所有的事务就会在新的回滚表空间内进行。

以下几种情况会导致切换命令失败

1.表空间不存在;
2..表空间不是一个回滚段表空间;
3.表空间已经被另一个实例使用。


注意:切换的操作不等待旧undo表空间的事务提交。如果旧undo表空间有事务未提交,那么旧的undo表空间进入pendingoffline状态,在这种模式下所有的事务能够继续进行,但是undo表空间不能被其他实例使用,也不能被删除,直到所有的事务提交后,undo表空间才进入offline模式。

7.设置undo_retention
dba可以设置undo_retention初始化参数指定undo回滚表空间保留undo信息的时间。在设置好这个参数时,系统会保留undo信息在指定的时间断后才收回这个空间。
一般情况下,系统会保留undo信息到指定的时间后才回收空间,但是,如果系统
存在大量的事务,也会将未到期的undo空间回收,以供使用。


8.Undo表空间大小的设计规范的计算公式
Undospace=UR*UPS*db_block_size+冗余量
UR表示在undo中保持的最长时间数(秒),由数据库参数UNDO_RETENTION值决定。
UPS表示在undo中,每秒产生的数据库块数量。


undo有关的动态性能视图v$undostat包含undo的统计信息。使用这张视图可以估计系统当前所需的undo大小。
v$rollstatundo模式的视图。是undo表空间的undosegments的统计信息
v$transaction包含undosegments的信息。
dba_undo_extents包含undo表空间中每一个范围的提交时间。


.管理回滚段

4.1回滚段的使用方针

4.1.1使用多个回滚段
使用多个回滚段来分担回滚段的争用,以提高系统性能。系统采用循环的方式来分配回滚段。当oracle创建数据库时候,系统自动在system中分配一个systemrollbacksegment,用来完成系统的事务,不为大家共用。所以系统最后能有至少一个回滚段存放用户回滚信息。


系统能够加载的用户回滚段数量和以下几个初始化参数有关:
transactions_per_rollback_segment指定每一个回滚段支持的并发数;
max_rollback_segments指明系统支持的最大的online的回滚段数目;
rollback_segments指定实例启动时所需要的回滚段;


4.1.2选择好回滚段的类型
private必须通过实例指定名称后才能使用。
如:必须在初始化参数中rollback_segments指定后,实例启动才能使用,或者在实例启动后online才能使用。
Public则是实例启动时系统自动发现,系统根据初始化参数决定系统启动时的回滚段。


4.1.3为事务指定回滚段
在系统启动时指定所需要的回滚段,

4.1.4估计回滚段的大小
回滚段大小应该基于系统最大的事务。如果回滚段过小,容易产生ora-01555错误。可以使用optimize选项来限制回滚段自动回收。回滚段的大小应该是最大表的大小的10%,这个可以指定maxextents的数量。


4.1.5创建范围大小和数量相等的回滚段组
一般来说一个回滚段应该包含1020个范围。
s=T/n
s是初始化时定义的范围的大小,T是初始化的回滚段大小,n是范围数。由此可以确定定义回滚段的子句的各个参数。


4.1.6定义optimal的值
设置这个参数可以避免回滚段无限扩展以及系统自动回收空间。最小是两个范围的大小。

设置回滚段在不同的表空间
1:如果系统只有一个回滚表空间,那么回滚段出现问题,影响系统不能运行。
2:包含回滚段的表空间经常分配和去配容易产生碎片。
3:当回滚表空间被离线时,系统将没有回滚表空间可以用。


MINEXTENTS最小等于2
OPTIMAL最小应该设置成两个extents大小
INITIALNEXT最好一样,除了应用使用指定的回滚段;

4.2回滚段的相关操作

4.2.1创建回滚段
当创建回滚段时,系统必须要有CREATEROLLBACKSEGMENT系统权限

创建的回滚段会online,并指定了存储参数;

CREATEROLLBACKSEGMENTRB01TABLESPACERBS1STORAGE(

INITIALintegerK|MNEXTintegerK|MMINEXTENTSintegerMAXEXTENTSintegerOPTIMALintegerK|M);


4.2.2修改回滚段

修改回滚段当修改回滚段时,系统必须要有ALTERROLLBACKSEGMENT系统权限

使回滚段online或者offline;
ALTERROLLBACKSEGMENTRB01ONLINE;

修改存储参数;
ALTERROLLBACKSEGMENTRB01STORAGE(MAXEXTENTS200OPTIMAL2048K);

收缩回滚段;
ALTERROLLBACKSEGMENTRB01SHRINK;
注意:OPTIMAL参数时,缩小到OPTIMAL;没有OPTIMAL参数时,缩小到MINEXTENTS所对应的尺寸

ALTERROLLBACKSEGMENTRB01SHRINKTO2048K;
ALTERROLLBACKSEGMENTRB01STAROGE(MAXEXTENTS120);


4.2.3删除回滚段
当删除回滚段时,系统必须要有DROPROLLBACKSEGMENT系统权限
原则上,INITIAL总应该等于NEXT,除了使用SETTRANSACTIONUSEROLLBACKSEGMENTXXX的回滚段。由于INITIAL不能直接修改,只能先drop然后创建。


DROPROLLBACKSEGMENTRB01;
CREATEROLLBACKSEGMENTRB01TABLESPACERBS1
STORAGE(INITIAL100KNEXT100KMINEXTENTS20MAXEXTENTS121OPTIMAL2000K);


在事务中使用特定的回滚段

SETTRANSACTIONUSEROLLBACKSEGMENTRB_LARGE1;


通过这个命令,可以:
根据事务量的大小,决定使用哪一个回滚段;
将大的查询的事务放入单独的回滚段;
当存在大的查询使用事务时,可以将它放入大的回滚段。


4.3和回滚段相关的性能视图


DBA_ROLLBACK_GEGS描述回滚段的信息,包含回滚段的名字和表空间;
DBA_SEGMENTS描述回滚段的附加信息;
V$ROLLNAME列出在线回滚段的名称
V$ROLLSTAT包含回滚段的统计信息
V$TRANSACTION包含撤销的统计信息

<!--EndFragment-->

 

五、UNDO表空间清理方法
1、新建一个Undotbs2的Undo表空间
create undo tablespace undotbs2 datafile
'/opt/oracle/.../UNDOTBS02.DBF'
size 1000m reuse autoextend on next 100m maxsize unlimited;
2、将系统的Undo表空间切换到Undotbs2上
alter system set undo_tablespace=undotbs2 scope=both;
3、Drop掉Undotbs1
drop tablespace UNDOTBS1 INCLUDING CONTENTS AND DATAFILES;
SQL> drop tablespace UNDOTBS1 including contents cascade constraints;
drop tablespace UNDOTBS1 including contents cascade constraints
*ERROR at line 1:
ORA-01548: active rollback segment '_SYSSMU6$' found, terminate dropping
tablespace

如果遇到上面的问题,清执行:
1). 找出具体的rollback segment,可能不止提示的那一个。
SQL> select segment_name from dba_rollback_segs where tablespace_name = 'UNDOTBS1';
SEGMENT_NAME
------------------------------
_SYSSMU123213$
_SYSSMU123214$

2).  生成一个新的pfile.

SQL> create pfile='/tmp/aaa_tmp.ora' from spfile;
File created.
SQL> 
3). 修改pfile,加上参数: _corrupted_rollback_segments
_corrupted_rollback_segments=(_SYSSMU123213$,_SYSSMU123214$)
4).  用新的pfile启动数据库。
SQL> shutdown immediate;
SQL> startup pfile='/tmp/aaa_tmp.ora'
SQL> drop tablespace UNDOTBS1 including contents and datafiles cascade constraints;
Tablespace dropped.
SQL>
5).  重新生成spfile。
SQL> create spfile from pfile='/tmp/aaa_tmp.ora';
SQL> shutdown immediate;
SQL> startup
OK!

4、重建Undotbs1
create undo tablespace undotbs1 datafile
'/opt/oracle/.../UNDOTBS01.DBF'
size 2000m reuse autoextend on next 100m maxsize unlimited;
5、将系统的Undo表空间切回到Undotbs1上
alter system set undo_tablespace=undotbs1 scope=both;
 6、Drop掉Undotbs2
drop tablespace UNDOTBS02 INCLUDING CONTENTS AND DATAFILES;

 



After a transaction is committed, undo data is no longer needed for rollback or transaction recovery purposes. However, for consistent read purposes, long-running queries may require this old undo information for producing older images of data blocks. Furthermore, the success of several Oracle Flashback features can also depend
upon the availability of older undo information. For these reasons, it is desirable to retain the old undo information for as long as possible.
When automatic undo management is enabled, there is always a current undo retention period, which is the minimum amount of time that Oracle Database attempts to retain old undo information before overwriting it. Old (committed) undo information that is older than the current undo retention period is said to be expired. Old undo information with an age that is less than the current undo retention period is said to be unexpired.
Oracle Database automatically tunes the undo retention period based on undo tablespace size and system activity. You can specify a minimum undo retention period (in seconds) by setting the UNDO_RETENTION initialization parameter. The database makes its best effort to honor the specified minimum undo retention period, provided that the undo tablespace has space available for new transactions. When available space for new transactions becomes short, the database begins to overwrite expired undo. If the undo tablespace has no space for new transactions after all expired undo is overwritten, the database may begin overwriting unexpired undo information. If any of this overwritten undo information is required for consistent read in a current long-running query, the query could fail with the snapshot too old error message.
The following points explain the exact impact of the UNDO_RETENTION parameter on undo retention:
The UNDO_RETENTION parameter is ignored for a fixed size undo tablespace. The database may overwrite nexpired undo information when tablespace space becomes low.For an undo tablespace with the UTOEXTEND option enabled, the database attempts to honor the minimum retention period specified by UNDO_RETENTION. When space is low, instead of overwriting unexpired undo information, the tablespace auto-extends. If the MAXSIZE clause is specified for an auto-extending undo tablespace, when the maximum size is reached, the database may begin to overwrite unexpired undo information.
Retention Guarantee
To guarantee the success of long-running queries or Oracle Flashback operations, you can enable retention guarantee. If retention guarantee is enabled, the specified minimum undo retention is guaranteed; the database never overwrites unexpired undo data even if it means that transactions fail due to lack of space in the undo tablespace. If retention guarantee is not enabled, the database can overwrite unexpired undo when space is low, thus lowering the undo retention for the system. This option is disabled by default.
WARNING: Enabling retention guarantee can cause multiple DML operations to fail. Use with caution.
You enable retention guarantee by specifying the RETENTION GUARANTEE clause for the undo tablespace when you create it with either the CREATE DATABASE or CREATE UNDO TABLESPACE statement. Or, you can later specify this clause in an ALTER TABLESPACE statement. You disable retention guarantee with the RETENTION NOGUARANTEE clause.You can use the DBA_TABLESPACES view to determine the retention guarantee setting for the undo tablespace. A column named RETENTION contains a value of GUARANTEE, NOGUARANTEE, or NOT APPLY (used for tablespaces other than the undo tablespace).
Automatic Tuning of Undo Retention
Oracle Database automatically tunes the undo retention period based on how the
undo tablespace is configured.If the undo tablespace is fixed size, the database tunes the retention period for the
best possible undo retention for that tablespace size and the current system load. This tuned retention period can be significantly greater than the specified minimum retention period.
If the undo tablespace is configured with the AUTOEXTEND option, the database tunes the undo retention period to be somewhat longer than the longest-running query on the system at that time. Again, this tuned retention period can be greater than the specified minimum retention period.Note: Automatic tuning of undo retention is not supported for LOBs. This is because undo information for LOBs is stored in the segment itself and not in the undo tablespace. For LOBs, the database attempts to honor the minimum undo retention period specified by UNDO_RETENTION. However, if space becomes low, unexpired LOB undo information may be overwritten.
You can determine the current retention period by querying the TUNED_UNDORETENTION column of the V$UNDOSTAT view. This view contains one row for each 10-minute statistics collection interval over the last 4 days. (Beyond 4 days, the data is available in the DBA_HIST_UNDOSTAT view.) TUNED_UNDORETENTION is given in seconds.
select to_char(begin_time, 'DD-MON-RR HH24:MI') begin_time,
to_char(end_time, 'DD-MON-RR HH24:MI') end_time, tuned_undoretention
from v$undostat order by end_time;
External Views
Monitor transaction and undo information with V$TRANSACTION and V$ROLLSTAT.
For automatic undo management, the information in V$ROLLSTAT reflects the
behaviors of the automatic undo management undo segments.
The V$UNDOSTAT view displays a histogram of statistical data to show how well the
system is working. You can see statistics such as undo consumption rate, transaction
concurrency, and lengths of queries run in the instance. Using this view, you can better
estimate the amount of undo space required for the current workload.

原创粉丝点击