Undo Management
Undo Management
TABLESPACE_NAME CONTENTS
----------------- ---------
UNDOTBS UNDO
UNDOTBS1 UNDO
In the above example, we have two UNDO tablespace listed. But only one of them can
be active and used by the system. The other one is currently not used.
So, the best way to view the current valid UNDO tablespace is by using “show
parameter” as shown below.
SQL> show parameter undo_tablespace
SUBSTR(FILE_NAME,1,60)
--------------------------------
/u01/oradata/devdb/undotbs_01.dbf
/u01/oradata/devdb/undotbs_02.dbf
/u01/oradata/devdb/undotbs_03.dbf
As we see from this output, this tablespace has only one datafile for the undo
tablespace.
2. View UNDO Total Space and Available Free Space
The following command will give you the total space used, and the free space still
available in the undo tablespace.
select
a.tablespace_name,
sum(a.bytes)/(1024*1024) total_space_MB,
round(b.free,2) Free_space_MB,
round(b.free/(sum(a.bytes)/(1024*1024))* 100,2) percent_free
from dba_data_files a,
(select tablespace_name,sum(bytes)/(1024*1024) free from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name(+)
group by a.tablespace_name,b.free
Output:
TABLESPACE_NAME TOTAL_SPACE_MB FREE_SPACE_MB PERCENT_FREE
---------------- -------------- ------------- ------------
UNDOTBS 2047 1809.44 88.39
The above command will display all the tablespace available in your system. Just
look for your undo tablespace from the list. The value displayed are in MB. The
last column PERCENT_FREE displays the total percentage of free space available
currently in UNDO tablespace.
3. Create New UNDO Tablespace
Creating an UNDO tablespace is similar to creating a regular tablespace.
The following example creates a new UNDO tablespace called UNDOTBS1.
C:\Users\Administrator>sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt
ions
NAME
---------
ORCL
TABLESPACE_NAME CONTENTS
------------------------------ ---------
UNDOTBS1 UNDO
no rows selected
SUBSTR(FILE_NAME,1,60)
--------------------------------------------------------------------------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DATAFILE\O1_MF_UNDOTBS1_JJ
SQL> select
2 a.tablespace_name,
3 sum(a.bytes)/(1024*1024) total_space_MB,
4 round(b.free,2) Free_space_MB,
5 round(b.free/(sum(a.bytes)/(1024*1024))* 100,2) percent_free
6 from dba_data_files a,
7 (select tablespace_name,sum(bytes)/(1024*1024) free from dba_free_space
8 group by tablespace_name) b
9 where a.tablespace_name = b.tablespace_name(+)
10 group by a.tablespace_name,b.free;
C:\Users\Administrator>sqlplus / as sysdba
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt
ions
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt
ions
Tablespace created.
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DATAFILE\UNDOTBS1_01.DBF
TABLESPACE_NAME CONTENTS
------------------------------ ---------
UNDOTBS1 UNDO
UNDOTBS2 UNDO
System altered.
FILE_NAME
--------------------------------------------------------------------------------
C:\APP\ADMINISTRATOR\ORADATA\ORCL\DATAFILE\O1_MF_UNDOTBS1_JJNZ9OT8_.DBF
SQL>