Procedure for Oracle undo to release a tablespace

Source: Internet
Author: User

Database Maintenance and programming are often difficult to understand in actual applications. After DML operations on large data volumes, we are extending the Oracle undo tablespace to a dozen or dozens of GB, but the physical space occupied by these tablespaces in the disk will not be released by Oracle, if you are using a PC, you may encounter insufficient disk space.

After completing the following operations, you can reconstruct the Oracle undo tablespace. Similarly, the temp tablespace may be infinitely expanded when you query big data or create an index, resulting in insufficient disk space, you can solve this problem as follows:

View table space names

 
 
  1. select name from v$tablespace 

View information about a tablespace

 
 
  1. select file_name,bytes/1024/1024 from 
    dba_data_files where tablespace_name like 'undoTBS1'; 

Check the usage of the rollback segment, which user is using the resources of the rollback segment, and if there is a user, it is best to change the time, especially in the production environment ).

 
 
  1. select s.username, u.name from v$transaction t,
    v$rollstat r, v$rollname u,v$session s  
  2. where s.taddr=t.addr and t.xidusn=r.
    usn and r.usn=u.usn order by s.username;  

Check the undo Segment status

 
 
  1. select usn,xacts,rssize/1024/1024/1024,hwmsize
    /1024/1024/1024,shrinks from v$rollstat order by rssize; 

Create a new undo tablespace and set automatic expansion parameters;

 
 
  1. create undo tablespace undotbs2 datafile 'D:\Oracle 
    \PRODUCT\10.1.0\ORADATA\ORCL\undoTBS02.DBF' size 10m 
    reuse autoextend on next 100m maxsize unlimited; 

Dynamically change the spfile configuration file;

 
 
  1. alter system set  undo _tablespace=undotbs2 scope=both; 

Wait for all Oracle undo segment offline for the original UNDO tablespace;

 
 
  1. select usn,xacts,status,rssize/1024/1024/1024,
    hwmsize/1024/1024/1024,shrinks from v$rollstat 
    order by rssize; 

Run the following command to check whether all UNDO segments in the UNDO tablespace are ONLINE;

 
 
  1. select usn,xacts,status,rssize/1024/1024/1024,
    hwmsize/1024/1024/1024,shrinks from v$rollstat 
    order by rssize; 

Delete the original UNDO tablespace;

 
 
  1. drop tablespace undotbs1 including contents; 

Check whether the deletion is successful;

 
 
  1. select name from v$tablespace; 

Finally, you need to manually delete the data file in the path where the data file is stored after restarting the database or the computer: the above steps only delete the logical relationship of the Oracle undo tablespace in Oracle, that is, the association between data files in the data dictionary is deleted, and the associated data files are not automatically deleted ).

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.