今天生产库进行FLASHBACK query闪回查询的时候遇到一个问题, ORA-01555: snapshot too old .......数据已经不能被闪回了...吸取教训了,在安装文档里就要对此项参数装完数据库后即刻作出调整。
我的环境是数据库版本是Oracle10g Release 2的,查看的数据库参数undo_retention设置,发现这个参数被在10g中缺省的被设置为900秒(15分钟),这个时间长度是太短了,再安装的时候忘记修改了,马上将这个参数修改为10800,3个小时:
ALTER SYSTEM SET undo_retention=10800 SCOPE=BOTH;
为什么是3个小时?
以前一度这个参数的缺省值被设为10800,可是随之而来的是UNDO表空间的过分扩展,难以回收,Oracle在不同版本中,也在进行不停的加权和折中。
Oracle也许会这样想:如果很少有人使用Flashback Query,而过大的undo_retention又会带来麻烦,那么干脆,设小点。
如何理解这个参数的作用呢?
链接:http://blog.csdn.net/seagal890/article/details/3044226
UNDO_TABLESPACE
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_tablespace string UNDOTBS1
SQL> show parameter undo_management;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_management string AUTO
SQL> show parameter undo_retention;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_retention integer 900
SQL>
|
Initialization Parameter
|
Description
|
UNDO_MANAGEMENT
|
If AUTO, use automatic undo management. The default is MANUAL
|
UNDO_TABLESPACE
|
An optional dynamic parameter specifying the name of an undo tablespace. This parameter should be used only when the database has multiple undo tablespaces and you want to direct the database instance to use a particular undo tablespace.
|
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.
|
CREATE UNDO TABLESPACE UNDOTBS01
DATAFILE
‘E:/oracle/product/10.2.0/oradata/keymen/UNDOTBS01.DBF’
SIZE 500M AUTOEXTEND ON
RETENTION GUARANTEE
|
ALTER DATABASE UNDOTBS01 RETENTION GUARANTEE
|
ALTER DATABASE UNDOTBS01 RETENTION NOGUARANTEE
|
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_NAME CONTENTS RETENTION ------------------------------ --------- ----------- SYSTEM PERMANENT NOT APPLY UNDOTBS1 UNDO NOGUARANTEE SYSAUX PERMANENT NOT APPLY TEMP TEMPORARY NOT APPLY USERS PERMANENT NOT APPLY 14 rows selected |