How Do I Recover From A Dropped Tablespace With RMAN

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

How do I recover from a dropped tablespace with RMAN?

Applies to:
Oracle Server - Enterprise Edition - Version: 10.2.0.2 Information in this document applies to any platform.

Solution
The RMAN duplicate command cannot be used for a drop tablespace as the current target controlfile being accessed by the duplicate would not have information about the datafiles associated with the drop tablespace. Also, you CANNOT use Tablespace Point In Time Recovery (TSPITR) to recover a dropped tablespace. Thus, you have one of two options based on your desired effect on the existing database: 1. Restore the entire database and recover back in time to before the tablespace is dropped. This will cause ALL data within the database to go back in time, not just this tablespace. 2. Clone the target database to a new location, perform point in time recovery in order to export the data of the tablespace for import into the original database. This causes the data of this tablespace to be brought back into the production database, not effecting existing (current) data in any other area of the database. OPTION #1: Restore target database and recover to a time before the tablespace is dropped: --------------1. Determine what 'set until' to use for the restore and recovery: - find the 'drop tablespace' statement in the alert.log of the target database. - looking at the time of the drop, subtract about 5 minutes, and record as the time to be used for the RMAN 'set until'. For example: Thu Aug 23 10:21:01 2007 Thread 1 advanced to log sequence 243 Current log# 2 seq# 243 mem# 0: /u01/V102_oradata/redo02.log Thu Aug 23 10:21:16 2007 drop tablespace test including contents and datafiles Thu Aug 23 10:21:19 2007 Deleted file /u01/temp/test01.dbf Completed: drop tablespace test including contents and datafiles The above shows the tablespace was dropped at 10:21 on Aug 23 2007. We also see that we began to write to sequence 243 just before the drop. Thus an appropriate 'set until' for RMAN would be:

Using time: --------------run { set until time "to_date('2007 Aug 23 10:15','yyyy mon dd hh24:mi')"; ........ ........ } Using Sequence: -----------------------run { set until sequence 243 thread 1; ........ ........ } NOTE: The above syntax tells RMAN to recover to sequence 242. 2. Shutdown the target database and startup with NOMOUNT option: RMAN> shutdown immediate; RMAN> startup nomount; 3. Restore a controlfile using the same 'set until'. RMAN> run { set until ........................; restore controlfile; } Note: See Note 403883.1 and/or Note 372996.1 for more detail on restoring the controlfile. 4. Mount the database: RMAN> alter database mount; 5. Restore and recover the database back in time. RMAN> run { set until ........................; restore database; recover database; } 6. Open the database with resetlogs option: RMAN> alter database open resetlogs;

OPTION #2: Clone database for data retrieval of dropped tablespace. --------------As the RMAN duplicate command cannot be used, you must restore and recover the target database back in time to before the 'drop tablespace'. The procedure would be the same as 'Option #1' above, but in a different location/server than the original target. Tablespaces not neeed can be 'skipped' using the 'skip forever tablespace' option of both the RESTORE and RECOVER commands. The tablespace data from this restore of the target can then be extracted to be inserted into the target database. NOTE: As this is not a duplicate command, the only method of changing datafile locations is through the use of 'SET NEWNAME'. The db_file_name_convert and log_file_name_convert are only valid with the RMAN duplicate command. Note 549972.1 'RMAN: SET NEWNAME Command Using SQL' may be of help.

References
Bug 3897724 - DUPLICATE FAILS THROUGH DROP TABLESPACE ON TARGET Note 223543.1 - How to Recover From a DROP / TRUNCATE / DELETE TABLE with RMAN Note 372996.1 - Using RMAN to Restore and Recover a Database When the Repository and Spfile/Init.ora Files Are Also Lost Note 403883.1 - How To Restore Controlfile From A Backupset Without A Catalog Or Autobackup Note 549972.1 - RMAN: SET NEWNAME Command Using SQL

You might also like