In actual operations, we often encounter this situation during database maintenance programming, that is, Oracle releases the undo tablespace, the following articles mainly describe how to release the undo tablespace in Oracle.
After performing DML operations on large data volumes, the Oracle undo tablespace must be extended to dozens of GB or dozens of GB, but the physical disk space occupied by these tablespaces 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 Oracle to release the 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 also solve this problem using the following methods:
View table space names
- select name from v$tablespace
View information about a tablespace
- 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 ).
- select s.username, u.name from v$transaction t,v$rollstat r, v$rollname u,v$session s
- where s.taddr=t.addr and t.xidusn=r.usn and r.usn=u.usn order by s.username;
Check the UNDO Segment status
- select usn,xacts,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
Create a new Oracle tablespace to release the UNDO tablespace and set automatic expansion parameters;
- 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;
- alter system set undo_tablespace=undotbs2 scope=both;
Wait for all undo segment offline of the original UNDO tablespace;
- 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;
- select usn,xacts,status,rssize/1024/1024/1024,
hwmsize/1024/1024/1024,shrinks from v$rollstat order by rssize;
Delete the original UNDO tablespace;
- drop tablespace undotbs1 including contents;
Check whether the deletion is successful;
- select name from v$tablespace;
Finally, you need to manually delete the data files in the path where the data files are stored after restarting the database or the computer: The preceding steps only delete the logical relationship between Oracle and undo tablespace, that is, the association between data files in the data dictionary is deleted, and the associated data files are not automatically deleted ).