undo表空间官方说明

Undo Retention


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 unexpired undo information when tablespace space becomes low.


For an undo tablespace with the AUTOEXTEND 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)..














撤消保留


事务提交后,撤销数据不再需要回滚或事务恢复的目的。但是,为了一致的读取目的,长时间运行的查询可能需要这个旧的撤消信息来生成较旧的数据块图像。此外,几个Oracle闪回功能的成功还取决于较旧的撤消信息的可用性。由于这些原因,希望尽可能保留旧的撤消信息。


启用自动撤销管理时,总是有一个当前的撤销保留期,这是Oracle数据库在覆盖之前尝试保留旧的撤消信息的最小时间。旧的(提交的)撤消信息比当前的撤销保留期更早被认为是过期的。旧的撤销信息的年龄小于当前的撤消保留期,据说未过期。


Oracle数据库根据撤消表空间大小和系统活动自动调整撤消保留期限。您可以通过设置UNDO_RETENTION初始化参数来指定一个最小的撤销保留期(以秒为单位)。数据库尽最大努力遵守指定的最小撤消保留期限,前提是撤消表空间具有可用于新事务的空间。当新事务的可用空间变短时,数据库开始覆盖过期的撤销。如果在所有到期的撤销被覆盖之后,撤销表空间没有用于新事务的空间,则数据库可以开始覆盖未到期的撤消信息。如果在当前长时间运行的查询中需要任何覆盖的撤消信息以进行一致性读取,则查询可能会失败并显示快照太旧的错误消息。


以下几点说明UNDO_RETENTION参数对撤消保留的确切影响:


对于固定大小的撤销表空间,UNDO_RETENTION参数将被忽略。表空间空间变小时,数据库可能会覆盖未到期的撤消信息。


对于启用了AUTOEXTEND选项的撤消表空间,数据库将尝试遵守由UNDO_RETENTION指定的最短保留期限。当空间不足时,而不是覆盖未到期的撤销信息,表空间自动扩展。如果为自动扩展的撤消表空间指定了MAXSIZE子句,则在达到最大大小时,数据库可能会开始覆盖未到期的撤消信息。


保留保证


为了保证长时间运行的查询或Oracle闪回操作的成功,您可以启用保留保证。如果启用保留保证,则保证指定的最小撤销保留;数据库不会覆盖未过期的撤消数据,即使这意味着事务由于在撤消表空间中缺少空间而失败。如果保留保证未启用,则数据库可以在空间不足时覆盖未到期的撤销,从而降低系统的撤消保留。该选项默认是禁用的。


警告:
启用保留保证会导致多个DML操作失败。谨慎使用。


通过在使用CREATE DATABASE或CREATE UNDO TABLESPACE语句创建撤消表空间时指定RETENTION GUARANTEE子句来启用保留保证。或者,您可以稍后在ALTER TABLESPACE语句中指定此子句。您使用RETENTION NOGUARANTEE子句禁用保留保证。


您可以使用DBA_TABLESPACES视图来确定撤消表空间的保留保证设置。名为RETENTION的列包含GUARANTEE,NOGUARANTEE或NOT APPLY的值(用于除undo表空间以外的表空间)。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值