How to shrink undo tablespace and release excess space

Source: Internet
Author: User
Recycle the Undo space using the following steps:

1. Confirmation Document
Sql> Select file_name,bytes/1024/1024 from Dba_data_files
  2  where tablespace_name like ' UNDOTBS1 ';

file_name
--------------------------------------------------------------------------------
bytes/1024/ 1024
---------------
+oradg/danaly/datafile/undotbs1.265.600173875
          27810

2. Check Undo segment Status
Sql> Select Usn,xacts,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks 2 from V$rollstat order by Rssize; USN xacts rssize/1024/1024/1024 hwmsize/1024/1024/1024 shrinks---------------------------------------------          ----------------------------0 0.000358582.000358582 0 2 0.071517944.071517944 0 3 0.13722229.            13722229 0 9 0.236984253.236984253 0 10 0          .625144958.625144958 0 5 1 1.22946167 1.22946167 0 8 0 1.27175903 1.27175903 0 4 1 1
         .27895355 1.27895355 0 7 0 1.56770325 1.56770325 0    1 0        2.02474976 2.02474976 0 6 0 2.9671936 2.9671936
 0 rows selected.

3. Create a new undo table space
sql> Create undo tablespace undotbs2;

Tablespace created.

4. Toggle the Undo table space for the new undo table space
Sql> alter system set UNDO_TABLESPACE=UNDOTBS2 Scope=both;

System altered.

5. Wait for the original undo table space all undo SEGMENT OFFLINE
Sql> Select Usn,xacts,status,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks 2 from V$rollstat ORDER by rssize


       ; USN xacts STATUS rssize/1024/1024/1024 hwmsize/1024/1024/1024 shrinks---------------------------------             -------------------------------------------------------0 ONLINE. 000114441          .000114441 0 0 ONLINE. 000114441.000114441 0 0 ONLINE. 000114441 000114441 0 0 ONL INE. 000114441.000114441 0 0 ONLINE. 000 114441 000114441 0 0 ONLINE. 000114441.00011444          1 0 1 ONLINE. 000114441.000114441 0 16  0 ONLINE                   .000114441.000114441 0 0 ONLINE. 00011444          1.000114441 0 0 ONLINE. 000114441.000114441 0 0 0 ONLINE. 000358582.000358582 0 USN Xac TS STATUS rssize/1024/1024/1024 hwmsize/1024/1024/1024 shrinks-------------------------------------------- --------------------------------------------6 0 PENDING OFFLINE 2.9671936 2.
 9671936 0 rows selected.

Look again:
11:32:11 sql>/USN xacts STATUS rssize/1024/1024/1024 hwmsize/1024/1024/1024 shrinks--------                     --------------------------------------------------------------------------------1 ONLINE             .000114441.000114441 0 0 ONLINE. 000114441          000114441 0 0 ONLINE. 000114441.000114441 0 0 ONLINE 000114441.000114441 0 0 Onli NE. 000114441.000114441 0 0 ONLINE. 0001           14441.000114441 0 0 ONLINE. 000114441.000114441          0/0 ONLINE. 000114441.000114441 0 18            0 ONLINE         .000114441.000114441 0 0 ONLINE. 000114441 .000114441 0 0 0 ONLINE. 000358582.000358582 0 1

1 rows selected.
 elapsed:00:00:00.00

6. Delete the original undo table space
11:34:00 sql> drop tablespace undotbs1 including contents;

Tablespace dropped.

elapsed:00:00:03.13

7. Check the space situation
Because of the ASM management I use, you can use the 10GR2 provided by the Asmcmd to view the space usage.
[Oracle@danaly ~]$ export oracle_sid=+asm
[oracle@danaly ~]$ asmcmd asmcmd>
du 
used_mb      mirror_ USED_MB
  21625               21625
asmcmd> exit

Space has been released.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.