Mounting a database from database files copied from a previous installation

oracleoracle-xe

I recently had on Oracle 11g Express database crash.

I have copied the .dbf files from C:\oraclexe\app\oracle\oradata\XE to another folder and reinstalled Oracle 11g Express.

The files are:

  1. Control.dbf
  2. sysaux.dbf
  3. system.dbf
  4. TEMP.DBF
  5. UNDOTBS1.DBF
  6. USERS.DBF

I want to remount the old database files, so that I can recover the database.

Can you please tell me how can I do this?

Best Answer

The information about database data files and online redo log files along with their paths is stored in the control file(s). The information about the control file path is stored in initialization parameter file (pfile) or in server parameter file (spfile).

So if you moved your data files, online redo log files and/or control file(s) you should update the paths in the appropriate files to reflect the changes before you can mount and open the database.

First, you alter you parameter file with new information after you successfully started the instance:

SQL> startup nomount;
SQL> alter system set control_files = '/oracle/data/control.dbf';

Then you mount the database so control file can be read and written:

SQL> alter database mount;

After database is mounted you can use RENAME FILE command to set the new pats to data files and online redo log files:

SQL> alter database rename file '/u01/data/sysaux.dbf'
  to '/oracle/data/sysaux.dbf';


SQL> alter database rename file '/u01/data/redo_1a.dbf'
  to '/oracle/data/redo_1a.dbf';

If your online redo is damaged – you didn't specify redo log files names in the list – and database was not shut down orderly, then data files and control file(s) are in inconsistent state and the only way to open your database is to restore and recover it from a previous backup.