以下主要内容来自ORACLE官方文档《How to Change the Existing Undo Tablespace to a New Undo Tablespace (文档 ID 431652.1)》,样例部分为本人测试环境,同时,为避免理解或翻译错误,将原文附上。如果错漏,请大家指正。


本文适用于所有平台上的,数据库版本为 10.2.0.1 to 11.2.0.3 [Release 10.2 to 11.2]的环境。


Before doing any action, please perform a Backup of the database, just in case something doesn't works we will have a point to go back.

操作前,请执行数据库备份,以便发生不能正常工作时可以恢复。


1. Determine the size of the datafile(s) for your current undo tablespace "UNDOTBS1":

  确认当前UNDO表空间“UNDOTBS1”的大小:

SQL> select bytes/1024/1024 "Size(M)",name from v$datafile where name like '%undo%';
  Size(M) NAME
---------- ----------------------------------------
      320 /oradata/orcl/undotbs01.dbf


2. Create a new undo tablespace of the same size (larger or smaller) depending on your database requirements.

  根据数据库的要求,创建一个新的表空间。

SQL> create undo tablespace UNDOTBS2 datafile '/oradata/orcl/undotbs02.dbf' size 320M;
Tablespace created.


3. Edit your init.ora file and change the parameter "undo_tablespace=" so it points to the newly created tablespace. You may need to create a pfile first:

  编辑init.ora文件修改参数“undo_tablespace=”指向新创建的表空间。为完成这一步,你可能需要首先创建一个pfile文件。

检查当前使用的参数文件是spfile,还是pfile.若VALUE列中有值,则表明正在使用SPFILE,否则为正在使用PFILE.
SQL> show parameter pfile;
NAME                                  TYPE       VALUE
------------------------------------ ----------- ------------------------------
spfile                                string     /oracle/app/oracle/product/10.2/db_1/dbs/spfileorcl.ora
创建pfile.(若上一步检查结果为正在使用pfile,则跳过此步)
SQL> create pfile from spfile;
File created.

编辑pfile(默认在$ORACLE_HOME/dbs目录下,文件名为init$ORACLE_SID.ora),修改以下参数和值。

Change undo_tablespace=UNDOTBS2
Change undo_management=MANUAL

Setting undo_management now ensures the old rollback segments can be taken offline and avoids editing the pfile and restarting the instance again in Step 7.

     现在设置 undo_management 是为了确保旧的回滚段可以被置为OFFLINE,并且避免在第7步时再一次编辑pfile文件和重启数据库实例。

4. Arrange a time when the database can be shutdown cleanly and perform a shutdown immediate.
  安排一个时间使用shutdown immediate关闭数据库

5. Startup the database (specify the pfile if you created one in step 3.)

  启动数据库(他用第3步创建的pfile文件)

SQL> startup pfile='/oracle/app/oracle/product/10.2/db_1/dbs/initorcl.ora'
ORACLE instance started.


6. Confirm the new tablespace is in use:

  确认新的表空间已经启用

SQL> show parameter undo_tablespace
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace                      string      UNDOTBS2


7. Check the status of the undo segments and determine if all the segments in the old undo tablespace are offline. The segments in the new tablespace may also show offline.

  检查回滚段的状态并且确认是否所有的旧UNOD表空间上的段都处于OFFLINE状态。新UNDO表空间中的段也有可能会显示为OFFLINE状态。

SQL> select owner,segment_name,tablespace_name,status from dba_rollback_segs order by 3;
OWNER  SEGMENT_NAME                   TABLESPACE_NAME                STATUS
------ ------------------------------ ------------------------------ ----------------
SYS    SYSTEM                         SYSTEM                         ONLINE
PUBLIC _SYSSMU1$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU10$                     UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU9$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU8$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU7$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU6$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU5$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU4$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU3$                      UNDOTBS1                       OFFLINE
PUBLIC _SYSSMU2$                      UNDOTBS1                       OFFLINE

PUBLIC _SYSSMU19$                     UNDOTBS2                       OFFLINE
PUBLIC _SYSSMU18$                     UNDOTBS2                       OFFLINE
....etc.

If the old segments are online, then they must be taken offline:

如果老的回滚段是ONLINE状态,那么必须使用它们处于OFFLINE状态。

SQL>alter rollback segment "_SYSSMU3$" offline;
SQL>alter rollback segment "_SYSSMU2$" offline;

This should be executed for all online rollback segments in the old tablespace.

     应对旧UNDO表空间中的所有ONLINE状态的回滚段执行上述的语句(将双引号中的段名改为相应的ONLINE状态的段名)。


8. Provided all the segments in the old undo tablespace are offline, you can now drop the old undo tablespace:

  如果所有旧UNDO表空间中的段均是OFFLINE状态的,则可以删除旧的UNDO表空间了。

SQL>drop tablespace UNDOTBS1 including contents and datafiles;

Tablespace dropped.


9. Recreate your spfile with the new undo_tablespace value and change undo_management to AUTO:

  重新创建你的SPFILE使用下面的新参数值(编辑PFILE文件并修改为新的参数值):

undo_management='AUTO'
undo_tablespace='UNDOTBS2'
SQL> create spfile='/oracle/app/oracle/product/10.2/db_1/dbs/spfileorcl.ora' from pfile='/oracle/app/oracle/product/10.2/db_1/dbs/initorcl.ora';
File created.


10. Shutdown the database (shutdown immediate) and restart it with the spfile.

   关闭数据库(shutdown immediate)然后使用SPFILE重新启动。