OracleDatabaseREAN recoveryOfData File recoveryThis is what we will introduce in this article. We know that apart from the system tablespace data file mount, other data files can be restored in the open (mount) state. Restoring data files in the open state can reduce the database downtime, so you should restore these data files in the open state.
Example 1: the data file is deleted by mistake.
Delete non-system tablespace data files when the database is closed.
Start the database to the mount status.
For offline data files, alter database datafile n offline.
Open the database and alter database open.
Dump the data file, restore datafile n.
Use recover datafile n to archive logs.
Online data file: alter database datafile n online.
-- Delete non-system tablespace data files when the database is closed.
- [Oracle @ localhost ~] $ Rm $ ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;
- SQL> select file #, error from v $ recover_file;
- FILE # ERROR
- ---------------------------------------------------------------------------
- 5 FILE NOT FOUND
- SQL> select file #, name from v $ datafile where file # = 5;
- FILE # NAME
- ------------------------------------------------------------------------------------------
- 5/oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf
- -- Restore data files
- RMAN> run {
- Startup force mount;
- SQL 'alter database datafile 5 offline ';
- SQL 'alter database open ';
- Restore datafile 5;
- Recover datafile 5;
- SQL 'alter database datafile 5 online ';
- 8>}
Example 2: the disk where the data file is located is damaged
Delete non-system tablespace data files when the database is closed.
Start the database to the mount status.
For offline data files, alter database datafile n offline.
Open the database and alter database open.
Before restore database, run set newname to specify a new location for the data file.
After the restore database, Run switch datafile to change the location and name of the data file in the control file.
Then, archive logs by executing the recover database application.
Online data file: alter database datafile n online.
-- Delete non-system tablespace data files when the database is closed.
- [Oracle @ localhost ~] $ Rm $ ORACLE_BASE/product/10.2.0/oradatabak/example01.dbf;
-
- SQL> select file #, error from v $ recover_file;
-
- FILE # ERROR
-
- ---------------------------------------------------------------------------
-
- 5 FILE NOT FOUND
-
- SQL> select file #, name from v $ datafile where file # = 5;
-
- FILE # NAME
-
- ------------------------------------------------------------------------------------------
-
- 5/oracle/10g/oracle/product/10.2.0/oradatabak/example01.dbf
-
- -- Restore data files
-
- [Oracle @ localhost ~] $ Rman target sys/oracle @ oralife nocatalog
-
- RMAN> run {
-
- 2> startup force mount;
-
- 3> SQL 'alter database datafile 5 offline ';
-
- 4> SQL 'alter database open ';
-
- 5> set newname for datafile 5 to '$ ORACLE_BASE/product/10.2.0/oradata/oralife/example01.dbf ';
-
- 6> restore datafile 5;
-
- 7> switch datafile 5;
-
- 8> recover datafile 5;
-
- 9> SQL 'alter database datafile 5 online ';
-
- 10>}
-
- SQL> select file #, name from v $ datafile where file # = 5;
-
- FILE # NAME
-
- ------------------------------------------------------------------------------------------
-
- 5/oracle/10g/oracle/product/10.2.0/oradata/oralife/example01.dbf
-
- SQL> select file #, error from v $ recover_file;
-
- No rows selected
Here is an introduction to the restoration of data files recovered by Oracle Database RMAN. I hope this introduction will be helpful to you!