在AUM模式下,我们知道UNDO_RETENTION参数用以控制事务提交以后undo信息保留的时间。该参数以秒为单位,9iR1初始值为900秒,在Oracle9iR2增加为10800秒。但是这是一个NO Guaranteed的限制。
也就是说,假如有其他事务需要回滚空间,而空间出现不足时,这些信息仍然会被覆盖。
很多时候这是不希望看到的。
从Oracle10g开始,假如你设置UNDO_RETENTION为0,那么Oracle启用自动调整以满足最长运行查询的需要。当然假如空间不足,那么Oracle满足最大答应的长时间查询。而不再需要用户手工调整。
同时Oracle增加了Guarantee控制,也就是说,你可以指定UNDO表空间必须满足UNDO_RETENTION的限制。
SQL alter tablespace undotbs1 retention guarantee;
Tablespace altered
SQL alter tablespace undotbs1 retention noguarantee;
Tablespace altered
在DBA_TABLESPACES视图中增加了RETENTION字段用以描述该选项:
SQL select tablespace_name,contents,retention from dba_tablespaces;
TABLESPACE_NAMECONTENTSRETENTION
------------------------------ --------- -----------
SYSTEM PERMANENT NOT APPLY
UNDOTBS1 UNDONOGUARANTEE
SYSAUX PERMANENT NOT APPLY
TEMP TEMPORARY NOT APPLY
USERSPERMANENT NOT APPLY
EYGLEPERMANENT NOT APPLY
TEST PERMANENT NOT APPLY
ITPUBPERMANENT NOT APPLY
TRANSPERMANENT NOT APPLY
BIGTBS PERMANENT NOT APPLY
TEMP2TEMPORARY NOT APPLY
TEMP03 TEMPORARY NOT APPLY
DFMBRC PERMANENT NOT APPLY
T2KPERMANENT NOT APPLY
14 rows selected
在Oracle官方文档上这样解释:
RETENTION Undo tablespace retention:
GUARANTEE - Tablespace is an undo tablespace with RETENTION specified as GUARANTEE
A RETENTION value of GUARANTEE indicates that uneXPired undo in all undo segments in the undo tablespace should be retained even if it means that forward going operations that need to generate undo in those segments fail.
NOGUARANTEE - Tablespace is an undo tablespace with RETENTION specified as NOGUARANTEE
NOT APPLY - Tablespace is not an undo tablespace.