Example 1: The tablespace data file is deleted by mistake.
Delete all data files corresponding to the tablespace in the open state.
Use alter tablespace... offline for recover offline tablespace in the open state.
Use restore tablespace... to dump all data files in the tablespace.
Use recover tablespace... to archive logs.
Finally, use alter tablespace... online to bring the tablespace online.
-- Delete all data files corresponding to the tablespace in the open state.
[Oracle @ localhost ~] $ Rm/oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf;
-- Restore tablespace
[Oracle @ localhost ~] $ Rman target sys/oracle @ oralife nocatalog
RMAN> run {
2> SQL 'alter tablespace users offline for recover ';
3> restore tablespace users;
4> recover tablespace users;
5> SQL 'alter tablespace users online ';
6>}
Example 2: the disk where the tablespace data file is located is faulty
Delete all data files corresponding to the tablespace in the open state.
Use alter tablespace... offline for recover offline tablespace in the open state.
Run set newname to specify a new location for the data file.
Use restore tablespace... to dump all data files in the tablespace.
Run switch datafile to change the location and name of the data file in the control file.
Use recover tablespace... to archive logs.
Finally, use alter tablespace... online to bring the tablespace online.
-- Delete all data files corresponding to the tablespace in the open state.
[Oracle @ localhost ~] $ Rm/oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf;
SQL> select * from t_user;
Select * from t_user
*
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time
ORA-01110: data file 4:
'/Oracle/10g/oracle/product/10.2.0/oradatabak/users01.dbf'
SQL> select file #, error from v $ recover_file;
FILE # ERROR
---------------------------------------------------------------------------
4 FILE NOT FOUND
-- Restore tablespace
[Oracle @ localhost ~] $ Rman target sys/oracle @ oralife nocatalog
Run {
SQL 'alter tablespace users offline for recover ';
Set newname for datafile 4 to '$ ORACLE_BASE/product/10.2.0/oradata/oralife/user01.dbf ';
Restore tablespace users;
Switch datafile all;
Recover tablespace users;
SQL 'alter tablespace users online ';
}
-- Recovered
SQL> select * from t_user;
TEXT
--------------------
Java _
SQL> select name from v $ datafile where file # = 4;
NAME
--------------------------------------------------------------------------------
/Oracle/10g/oracle/product/10.2.0/oradata/oralife/user01.dbf
Data Block Media recovery
If some data blocks in the data file are damaged, use the blockrecover command to restore the damaged data blocks.
For example:
RMAN> blockrecover device type disk
2> datafile 5 blocks, 88;
We will introduce the restoration methods for tablespace and data block media in Oracle Database RMAN recovery. We hope this introduction will help you.
Author: "oracle certification value"