Recovering a Corrupted Oracle UNDO Tablespace
This article describes a recovery procedure for Oracle Database environments where corruption or recovery issues affecting UNDO segments prevent normal database operations. In certain cases, the database may report errors such as ORA-00376 when attempting to access datafiles associated with the UNDO tablespace.
The procedure involves identifying problematic rollback segments, temporarily switching the database to manual undo management, creating a replacement UNDO tablespace, and restoring automatic undo management.
Important: This procedure is intended for exceptional recovery scenarios. UNDO contains transactional information required for rollback, read consistency, and transaction recovery. Changing undo management and dropping rollback segments or tablespaces should only be performed after a careful assessment of the database state, backup availability, and recovery requirements.
1. Identifying the Corrupted UNDO Segments
The first step is to identify the rollback segments that are in an abnormal state. The DBA_ROLLBACK_SEGS data dictionary view provides information about rollback segments, including their status and associated tablespace.
Execute the following query to identify segments that require recovery:
SELECT segment_name, status, tablespace_name FROM dba_rollback_segs WHERE tablespace_name = 'UNDOTBS1' AND status = 'NEEDS RECOVERY';
Example output:
SEGMENT_NAME STATUS TABLESPACE_NAME
----------------- --------------- ----------------
_SYSSMU22$ NEEDS RECOVERY UNDOTBS1
In this example, the rollback segment _SYSSMU22$ is in a NEEDS RECOVERY state.
If multiple segments are affected, identify all of them before proceeding. The recovery procedure must account for every problematic segment in the affected UNDO tablespace.
2. Shut Down the Database
Before making changes to the undo management configuration, shut down the database instance.
SHUTDOWN IMMEDIATE;
If the database cannot be shut down normally because of the corruption, the shutdown method may need to be adjusted according to the database’s current condition.
3. Prepare a PFILE with Manual Undo Management
Create a temporary initialization parameter file (PFILE) based on the current SPFILE or PFILE configuration.
The following parameters must be configured for the recovery procedure:
UNDO_MANAGEMENT=MANUAL
_OFFLINE_ROLLBACK_SEGMENTS=_SYSSMU22$
If more than one rollback segment is affected, specify all problematic segments.
For example:
UNDO_MANAGEMENT=MANUAL
_OFFLINE_ROLLBACK_SEGMENTS=('_SYSSMU22$','_SYSSMU23$','_SYSSMU24$')
The _OFFLINE_ROLLBACK_SEGMENTS parameter is an undocumented Oracle initialization parameter. Its use should be carefully evaluated and, where possible, performed under Oracle Support guidance.
The purpose of this configuration is to prevent Oracle from attempting to bring the identified problematic rollback segments online during instance startup.
Start the database in restricted mode and mount it using the temporary PFILE:
STARTUP RESTRICT MOUNT
PFILE='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/initORCL.ora';
The database should remain mounted and restricted while the recovery operations are performed.
4. Remove the Corrupted Rollback Segments and UNDO Tablespace
Once the database has been mounted successfully with the temporary configuration, remove the affected rollback segment.
DROP ROLLBACK SEGMENT "_SYSSMU22$";
Example output:
Rollback segment dropped.
If multiple rollback segments have been identified as corrupted, repeat the operation for each segment, provided Oracle permits the operation and the recovery assessment confirms that it is safe.
Next, remove the problematic UNDO tablespace.
DROP TABLESPACE UNDOTBS1
INCLUDING CONTENTS AND DATAFILES;
This command removes the tablespace, its contents, and its associated datafiles.
Warning: The INCLUDING CONTENTS AND DATAFILES clause is destructive. Verify the tablespace name, datafile locations, backup availability, and recovery requirements before executing this command.
If Oracle reports that the tablespace cannot be dropped because of active or unrecovered transactions, do not attempt to force the operation without investigating the underlying transaction recovery condition.
5. Create a New UNDO Tablespace
After successfully removing the corrupted UNDO tablespace, create a replacement tablespace.
The following example creates a new UNDO tablespace named UNDOTBS1:
CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE '/oradata/ORCL/UNDOTBS01.DBF' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED;
Adjust the datafile location, initial size, auto-extension settings, and maximum size according to your storage architecture and database workload.
For ASM-managed storage, the datafile can be created using an ASM disk group, for example:
CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE '+DATA' SIZE 2G AUTOEXTEND ON NEXT 256M MAXSIZE 20G;
The sizing values shown above are examples only. The new UNDO tablespace should be sized according to the database’s transaction workload, retention requirements, and available storage capacity.
6. Shut Down the Database
After creating the replacement UNDO tablespace, shut down the database.
SHUTDOWN IMMEDIATE;
7. Restore Automatic Undo Management
Edit the temporary PFILE and remove the recovery-related parameter:
_OFFLINE_ROLLBACK_SEGMENTS
Change the undo management configuration back to automatic mode:
UNDO_MANAGEMENT=AUTO
UNDO_TABLESPACE=UNDOTBS1
If the replacement UNDO tablespace has a different name, update the UNDO_TABLESPACE parameter accordingly.
The final PFILE should no longer contain the temporary rollback-segment configuration.
8. Start the Database Normally
Start the database using the updated PFILE:
STARTUP PFILE='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/initORCL.ora';
If the database starts successfully, verify the undo management configuration.
SHOW PARAMETER undo_management;
SHOW PARAMETER undo_tablespace;
Expected configuration:
NAME TYPE VALUE
--------------------- ----------- ----------
undo_management string AUTO
undo_tablespace string UNDOTBS1
Confirm that the new UNDO tablespace is online:
SELECT tablespace_name, status, contents FROM dba_tablespaces WHERE contents = 'UNDO';
Expected result:
TABLESPACE_NAME STATUS CONTENTS
--------------- --------- --------
UNDOTBS1 ONLINE UNDO
Finally, check the rollback segment status:
SELECT segment_name, status, tablespace_name FROM dba_rollback_segs WHERE tablespace_name = 'UNDOTBS1' ORDER BY segment_name;
The newly created undo segments should be available for normal database operations.
9. Recreate the SPFILE (Optional)
If the database was started using a PFILE and you want to return to SPFILE-based startup, create a new SPFILE using the updated PFILE:
CREATE SPFILE FROM PFILE;
If you need to specify the SPFILE location explicitly:
CREATE SPFILE='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/spfileORCL.ora'
FROM PFILE='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/initORCL.ora';
Restart the database using the newly created SPFILE and verify that all initialization parameters are configured correctly.
10. Post-Recovery Validation
After the database has been successfully opened, perform the following validation steps:
-
Confirm that the database is open and operating normally.
-
Verify that automatic undo management is enabled.
-
Confirm that the new UNDO tablespace is online.
-
Check the status of the undo segments.
-
Review the alert log for any remaining undo-related errors.
-
Validate application connectivity and critical database operations.
-
Take a new database backup as soon as possible.
For example, verify the database status:
SELECT name, open_mode, database_role FROM v$database;
Check the instance status:
SELECT
instance_name,
status,
database_status
FROM
v$instance;
Conclusion
Corruption affecting Oracle UNDO segments can prevent a database from starting normally or cause database operations to fail with errors such as ORA-00376.
In certain recovery scenarios, replacing the corrupted UNDO tablespace may provide a way to restore database availability. The process involves identifying the affected rollback segments, temporarily switching to manual undo management, removing the corrupted segments and tablespace, creating a replacement UNDO tablespace, and returning the database to automatic undo management.
However, replacing a corrupted UNDO tablespace is not equivalent to recovering the lost transactional information. Uncommitted transactions, transaction recovery, and data consistency must be carefully evaluated before proceeding.
Whenever possible, restoring and recovering the original UNDO datafiles using RMAN or another supported recovery method should be prioritized over discarding the affected UNDO contents. Oracle recommends automatic undo management for normal database operations, and manual undo management should be used only when necessary for a specific recovery or compatibility scenario.












