User-defined database recovery
First, automatic application redo log
1. Use the set autorecovery command to automatically apply the redo log
Complete repair operations for data files
SQL> Startup Mount; Start the instance and load the database
SQL> Set Autorecovery ON Enables Heavy Log Auto Application Function
SQL> Recover Database Recovery Specify Table Space, Data File, or Out of Database
SQL> ALTER DATABASE Open; Open the database after completing recovery
2, use the recovery automatic command to automatically apply the redo log
Complete repair operations for data files
SQL> Startup Mount; Start the instance and load the database
SQL> Recover Automatic Database
SQL> ALTER DATABASE Open; Open the database after completing recovery
Second, database media recovery in non-archive mode
1. Restore the database to the original position
SQL> Shutdown Immediate If the database is still in an open state, turn off the database;
Returning the database file to the original location, using the most recent consistency full backup to recover the entire database, you must repair all data files with the control file;
SQL> Recover Database Until Cancel
SQL> CANCEL
SQL> ALTER DATABASE OPEN RESETLOGS; set the current redo logs to 1.
2. Restore the database to a new location
SQL> Shutdown Immediate If the database is still in an open state, turn off the database;
Restore the database file to a new location, using the most recent consistency full backup of the entire database, you must repair all the data files with the control file;
Editing the Control_Files parameters in the initialization parameter file, so that it performs control files saved in the new location;
SQL> Startup Mount
If the fixed database file is in a new location, you must modify the control file using the ALTER DATABASE RENAME FILE statement to point to the data file after the new location. Such as:
SQL> Alter Database Rename File 'i: /ora9i/oradata/system01.dbf' to 'k: /oracle/oradata/system01.dbf';
SQL> Recover Database Until Cancel
SQL> CANCEL
SQL> ALTER DATABASE OPEN RESETLOGS; set the current redo logs to 1.
Third, complete media recovery in archiving mode
1. Complete recovery in the closed state
SQL> Shutdown Abort (If the database is open, turn it off)
Restore the data file to the original location, if the media failure cannot be excluded, you need to restore the data file to other locations;
Use backup to repair missing or damaged data files, you can also use the ALTER DATABASE CREATE DATAFILE statement to rebuild a blank data file replacement a pair or corrupted data file;
SQL> Startup Mount
If the repaired data file is not in the original location, you need to use the ALTER DATABASE RENAME FILE ... TO ... statement to update their information in the control file.
SQL> Select Name, Status from V $ dataFile; Query the name and status of the data file
SQL> ALTABASE DATAFILE ... Online; change the offline data file uncloiled SQL> Recover Database or SQL> Recover TableSpace users
Or SQL> Recover DataFile 'i: /ora9i/oradata/users0.dbf;
SQL> ALTABASE OPEN;
2. Complete media recovery in the open state
SQL> SELECT D.FILE # F #, D.Name, D.Status, H.Status from V $ DataFile D, V $ DataFile_Header H
WHERE D.FILE # = H.File #; Query which data files are automatically set to offline;
SQL> ALTER TABLESPACE OFFLINE TEMPORY; setting tablespace containing corrupted data files is offline;
Restore the data file to the original location, if the media failure cannot be excluded, you need to restore the data file to other locations;
Use backup to repair lost or corrupted data files;
If the repaired data file is not in the original location, you need to use the ALTER DATABASE RENAME FILE ... TO ... statement to update their information in the control file.
SQL> Recover TableSpace Users Automatic recovers the offline table space that contains corrupted data files;
SQL> ALTER TABLESPACE USERS Online;
Fourth, incomplete media recovery in archiving mode
1. Operating guidelines for incomplete recovery;
Full backups of databases before and after recovery
After completing the incomplete media recovery, check if the database has returned to the status of the target moment;
After completing the incomplete media recovery, move the archive redo log file to other locations.
2, time-based incomplete recovery
A complete backup of the database, including control files and all online redo log files
SQL> Shutdown Abort
Determine the target time of incomplete media recovery, that is, which time you need to restore the database, then determine which backups need to be used to fix the data, the database backup used by the database repair should be able to correctly reflect the target moment The database's physical structure, the data file backup used should be created before the target time, and all data files must be fixed.
If you don't have a data file backup established before the target moment, you need to recreate a blank data file.
If the data file established after the target time is included in the database, do not fix this data file, because this data file should not be present at all in the database after completion of the incomplete recovery;
Returning the data file to the original location, if the media failure cannot be excluded, it will be restored to other locations;
Repair all control files and data files using the selected backup file;
SQL> Startup Mount launches the instance and load the database;
If the repaired data file is not in their original location, you need to use the ALTER DATABASE RENAME FILE ... TO ... statement to update their information in the control file;
SQL> SELECT NAME, Status from V $ datafile; determine that all data files are online
SQL> ALTER DATABASE DATAFILE ... Online; Restore data files to online;
SQL> Recover Database Until Time '2004-02-01: 12: 30: 30'
If the control file uses backup repair, you must specify the use of backup controlfile clauses in Recover fame or fortune; SQL> ALTER DATABASE OPEN RESETLOGS;
Immediately turn a full backup of the database.
3, unfained recovery based on revoking
SQL> Recover Database Until Cancel
Other steps are based on time-based incomplete recovery
4. Distribution based on SCN-based incomplete recovery
When the SCN-based incomplete recovery is performed, Oracle will terminate the recovery process after applying all the recovery of transactions that are less than or equal to the specified SCN.
Resetlogs options
In the following three cases, you must open the database using the ResetLogs option:
1. After performing any type of incomplete medium recovery;
2, after using the backup repair control file (using the use backup controlfile clause) in the regover command);
After the not archive database is completely recovered without an online redo log file backup.