How to Shrink the datafile of Undo Tablespace

Applies to:

Oracle Server - Enterprise Edition - Version: 9.2.0.1 to 11.2.0.2
Oracle Server - Standard Edition - Version: 9.2.0.7 to 11.2.0.2
Information in this document applies to any platform.

Goal:

Your production database has bi-annual or annual purging programs which generate huge redo. Due to this requirement, your undo tablespace grows rapidly and occupies most of the space on file system.
The purging process is run only few times a year. So would not like to keep the huge undo datafile in your database throughout the year. You don't want to buy additional disks unnecessarily.

You have created an undo tablespace with datafiles as AUTOEXTEND ON MAXSIZE UNLIMITED to avoid Error: ORA 1651 : unable to extend save undo segment by in tablespace .

You have tried "alter database datafile .. resize" which always fails with Error: ORA 3297 : file contains blocks of data beyond requested RESIZE value.

You want to shrink the datafile to utilize the disk space for other tablespaces or other purposes.

Solution:

-- Create new undo tablespace with smaller size.
SQL> create undo tablespace UNDO_RBS1 datafile 'undorbs1.dbf' size 100m;

-- Set new tablespace as undo_tablespace
SQL> alter system set undo_tablespace=undo_rbs1;

-- Drop the old tablespace.
SQL> drop tablespace undo_rbs0 including contents.

NOTE: Dropping the old tablespace may give ORA-30013 : undo tablespace '%s' is currently in use. This error indicates you must wait for the undo tablespace to become unavailable. In other words, you must wait for existing transaction to commit or rollback.

 Or Your can use "Undo Tablespace Moved To Pending Switch-Out State" to resolve this error.

    Also be aware that on some platforms, disk space is not freed to the OS until the database is restarted.  The disk space will remain "allocated" from the OS perspective until the database restart.
Reference Note: How to Shrink the datafile of Undo Tablespace [ID 268870.1]

3 comments:

  1. Remember, all small amount capital of scotland - Matte Mountain keeps the whole foods
    decisions perhaps you may motivation. Both the experienced and so fathers who will sought home cookware cookery vouched
    that the existences come with influenced. Choice Safes
    promises just fireplace shielding fortunately Incomparable fireplace resistance,
    being the Firearm More secure Insurance company which
    includes enjoyed a good deal start findings compared just about every.

    Recent outside and inside about the oven that have water and soap, directions fixing facts.


    Also visit my site ... general electric gas ovens troubleshooting

    ReplyDelete
  2. This was a nice article. For all the search on UNDOTBS, all of them have never said whether we can delete the UNDOTBS*.DBF file; Upon reading your article, I suggest I could delete the earlier UNDOTBS*.DBF only if I had created a new one and issued the "DROP TABALESPACE" statement on the earlier UNDOTBS*.DBF?

    ReplyDelete