The Problem
New Undo tablespace was created and a attempt is made to drop old undo tablespace. Dropping the old Undo tablespace give message:
ORA-01548: active rollback segment
Or
Undo segment shows status as needs recovery
The Solution
The issue could happen if the datafile on which the undo segments reside is offline and the transaction cannot be rolled backed since the file is offline or this could also happen if there is any issue in the Undo segment itself.
Check Undo Segment
Check if the Undo segment status first:
SQL> select segment_name,status,tablespace_name from dba_rollback_segs where status not in ('ONLINE', 'OFFLINE') ; SEGMENT_NAME STATUS TABLESPACE_NAME ----------------- ----------- ---------------- _SYSSMU3$ NEEDS RECOVERY UNDO01
In the above example Undo segment _SYSSMU3$ is in Needs recovery status. This segment belongs to Undo tablespace UNDO01. Check the status of the datafile present in the tablespace UNDO01.
SQL> select status, name, file# from v$datafile where ts# in (Select ts# from v$tablespace where name='UNDO01' ); STATUS NAME FILE# ------- -------------------------------------------------- ---------- ONLINE /[UNDO]/[FILE_NAME].dbf 56 RECOVER /[UNDO]/[FILE_NAME].dbf 77
So clearly one file is in Recover status. If the database is in Archive log mode and you have all the required archive log mode you can do the following:
1. Find if you have all the required Archive logs on disk or If using Rman ensure they exist in the backup:
SQL> Select checkpoint_change# from v$datafile_header where file#=[file#(number) in RECOVER status from previous query];
2. Now find these changes are present in which Archive log:
SQL> select sequence#,thread#,name from v$archived_log where [checkpoint_change# from query 1] between first_change# and next_change# ;
Ensure you have all the archive logs starting from this sequence# till the current sequence# in your database. For example:
SQL> select checkpoint_change#,file#,status from v$datafile_header where file#=77; CHECKPOINT_CHANGE# FILE# STATUS ------------------ ---------- ------- 2103113 4 OFFLINE 77
SQL>Select sequence#,thread#,name from v$archived_log where 2103113 between first_change# and next_change# ; SEQUENCE# THREAD# NAME -------------------------------------------------------------------------------- 96 1 /[DIRECTORY]/[FILE_NAME].Arc
If using rman – check if the archive log from this sequence till current sequence is available:
RMAN> list backup of archivelog from sequence [No listed in step 2 query above]; RMAN> recover datafile [fileno]; RMAN> sql 'alter database datafile [fileno] online' ;
if using sqlplus – ensure the archive logs are present on disk:
SQL> recover datafile [fileno] ;
Type AUTO and hit enter. Once recovery is done execute below query:
SQL> alter database datafile [fileno] online ;
If the archive logs have been restored to a different location than the Default archive log destination your database is using then specify the same using set source command in sqlplus:
SQL> set logsource "/[DIR]/newlocation" ; SQL> recover datafile [fileno] ;
Type AUTO and hit enter. Once recovery is done, execute the below query:
SQL> alter database datafile [fileno] online ;