Anda di halaman 1dari 4

10/3/2016 Document 783471.

Recover from DROP TABLESPACE using Flashback Database (Doc ID 783471.1)

In this Document

Purpose
Scope
Details

APPLIES TO:

Oracle Database ­ Enterprise Edition ­ Version 10.2.0.4 to 11.1.0.7 [Release 10.2 to 11.1]
Information in this document applies to any platform.
Information in this document applies to any platform.

PURPOSE

This document shows how to recover from a DROP TABLESPACE statement using Flashback Database.

SCOPE

To recover from DROP TABLESPACE using Flashback Database, the following conditions must be met:

A backup of the tablespace must exist prior to when the DROP TABLESPACE was issued.
All archived log files must exist from when the backup was created to when the DROP TABLESPACE was
issued.

DETAILS

1. In the alert log, Oracle records the time that a DROP TABLESPACE statement is issued and the time it completes.
Find the message indicating the DROP TABLESPACE statement was issued. For example:

Tue Feb 17 10:02:02 2009
 
drop tablespace ts1 including contents and datafiles

2. Ensure that the database can be flashed back to before the DROP TABLESPACE command. If the time returned
by the query below is later than when the DROP TABLESPACE statement was issued, then flashback database
cannot be used to recover the tablespace.

SQL> select to_char(oldest_flashback_time,'Dy Mon DD HH24:MI:SS YYYY')
from v$flashback_database_log;  
   
TO_CHAR(OLDEST_FLASHBACK
­­­­­­­­­­­­­­­­­­­­­­­­ 
Wed Feb 10 19:34:12 2009 

3. Flashback the database to before the DROP TABLESPACE command. Use the date stamp taken from the alert
log.

RMAN> run {
   
# Flashback database requires a mounted database
 
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl­state=g6hdrkj8y_869&id=783471.1 1/4
10/3/2016 Document 783471.1

shutdown immediate;
startup mount;  
   
# Flashback the database to just before the DROP occurred
flashback database to before time  
 
"to_date('Tue Feb 17 10:02:02 2009','Dy Mon DD HH24:MI:SS YYYY')";
}  

Note that during the flashback database operation the datafiles that were part of the dropped tablespace are added
back into the control file as UNNAMED datafiles. The UNNAMED datafile name and the name the datafile was
originally created as are required to properly recover the dropped tablespace.

Recovery deleting file #6:'/u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00006' from contro
Recovery deleting file #7:'/u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00007' from contro
Recovery dropped tablespace 'TS1'
 
Flashback recovery: Added file #6 to control file as OFFLINE and 'UNNAMED00006'
because it was dropped during the flashback interval  
or it was added during flashback media recovery.  
File was originally created as:  
 
'+ENG/demo/datafile/ts1.14360.679053609'
 
File will have to be restored from a backup or
 
recreated using ALTER DATABASE CREATE DATAFILE command,
and the file has to be onlined and recovered.  
 
Flashback recovery: Added file #7 to control file as OFFLINE and 'UNNAMED00007'
because it was dropped during the flashback interval  
or it was added during flashback media recovery.  
File was originally created as:  
 
'+ENG/demo/datafile/ts1.17165.679053609'
 
File will have to be restored from a backup or
 
recreated using ALTER DATABASE CREATE DATAFILE command,
and the file has to be onlined and recovered.  
   

Note: It is possible to open the database READ ONLY to query data that exists outside the dropped tablespace to
determine whether or not the flashback operation should proceed (data within the dropped tablespace is not
available until it is recovered in a subsequent step). If you wish to continue with the flashback database operation
after opening the database READ ONLY, then SHUTDOWN and STARTUP MOUNT the database before proceeding
to the next step.

4. Ensure a backup exists of the tablespace prior to it being dropped. Use the date stamp taken from the alert log. 
Crosscheck the backup to verify status.

RMAN> list backup of tablespace ts1 completed before 
 
"to_date('Tue Feb 17 10:02:02 2009','Dy Mon DD HH24:MI:SS YYYY')";
   
List of Backup Sets
=================== 
   
 
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
­­­­­­­ ­­­­ ­­ ­­­­­­­­­­ ­­­­­­­­­­­ ­­­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­ 
5       Full    184.00K    DISK        00:00:01     17­FEB­09 10:00:42 
 
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20090217T100041
 
        Piece Name: +ENG/demo/backupset/2009_02_17/nnndf0_tag20090217t100041_0.9705.679053641
  List of Datafiles in backup set 5
 
  File LV Type Ckp SCN    Ckp Time           Name
  ­­­­ ­­ ­­­­ ­­­­­­­­­­ ­­­­­­­­­­­­­­­­­­ ­­­­ 
 
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl­state=g6hdrkj8y_869&id=783471.1 2/4
10/3/2016 Document 783471.1

  6       Full 1039902    17­FEB­
09 10:00:41 /u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00006
  7       Full 1039902    17­FEB­  
09 10:00:41 /u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00007
   

Crosscheck the backup to verify status.

RMAN> crosscheck backup of tablespace ts1 completed before
 
"to_date('Tue Feb 17 10:02:02 2009','Dy Mon DD HH24:MI:SS YYYY')";
   
using channel ORA_DISK_1
 
crosschecked backup piece: found to be 'AVAILABLE'
 
backup piece handle=+ENG/demo/backupset/2009_02_17/nnndf0_tag20090217t100041_0.9705.679053641 RECID
Crosschecked 1 objects
   

If there is no valid backup of the tablespace, then the tablespace cannot be recovered. The flashback database
command should be abandoned by running RECOVER DATABASE.  Refer to Oracle Database Backup and Recovery
User's Guide for details.

5. If there exists a valid backup for the dropped tablespace, then continue with recovery of the dropped tablespace
and opening the database. During this step, all UNNAMED datafiles must be renamed back to their proper name
with SET NEWNAME. This information is taken from the alert log output identified above.

RMAN> run {
   
# Rename the UNNAMED datafiles back to their original names.
 
# There will be one SET NEWNAME command for each UNNAMED datafile.
set newname for  
 
  datafile '/u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00007'
  to '+DATA/demo/datafile/ts1.17165.679053609';  
   
set newname for
 
  datafile '/u01/app/oracle/product/11.1.0/11.1.0.7/db/dbs/UNNAMED00006'
  to '+DATA/demo/datafile/ts1.14360.679053609';  
   
# Restore the files from the backup
 
# and switch the controlfile to point to them
restore tablespace ts1;  
switch datafile all;  
   
# Open resetlogs ­ required for flashback database
alter database open resetlogs;  
   
# Recover and online the tablespace that was dropped
recover tablespace ts1;  
 
sql "alter tablespace ts1 online";
}  

Didn't find what you are looking for?

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl­state=g6hdrkj8y_869&id=783471.1 3/4
10/3/2016 Document 783471.1

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl­state=g6hdrkj8y_869&id=783471.1 4/4

Anda mungkin juga menyukai