Creating Oracle Restore Points


You can give a name to a particular point in time, or an SCN number. This is useful for future reference, when performing point-in-time recovery or flashback operations.


Creates a restore point that represents the present point in time. If you were about to apply an update of an application or data in the database, and you wanted to refer back to this state of the database, you could use the BEFORE_MODS restore point.
SQL> CREATE RESTORE POINT before_mods

Creates a restore point representing a past SCN, 100. This restore point can be used in the same ways as the previous one.

Normally, restore points are maintained in the database for at least as long as specified by the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter. However, you can use the PRESERVE option when creating a restore point, which causes the restore point to be saved until you explicitly delete it.

SQL> CREATE RESTORE POINT end_q1 AS OF SCN 100;

Performing Incomplete Recovery
You can perform server-managed incomplete recovery using the following steps. The database must be in ARCHIVELOG mode.

1. Determine the restore target. This can be in terms of a date and time, an SCN, restore point, or log sequence number. For example, if you know that some bad transactions were submitted at 1:00 PM yesterday, then you can choose 12:59 PM yesterday as the target restore point time.

2. Set the native language support (NLS) OS environment variables, so that the time constants you provide to RMAN are formatted correctly. These are some example settings:

$ export NLS_LANG = american_america.us7ascii
$ export NLS_DATE_FORMAT = "yyyy-mm-dd:hh24:mi:ss"

3.  Mount the database. If it is open, you have to shut it down first, as in this example:

SQL> shutdown immediate
SQL> startup mount

4. Create a RUN block and run it. The RECOVER and RESTORE commands should be in the same RUN block so that the UNTIL setting applies to both. For example, if you choose to recover to a particular SCN, the RESTORE command needs to know that value so it restores files from backups that are sufficiently old—that is, backups that are from before that SCN. Here is an example of a RUN block:

RUN
{
  SET UNTIL TIME '2011-08-11:12:59:00';
  RESTORE DATABASE;
  RECOVER DATABASE;
}

3.   As soon as you open the database for read/write, you have committed to the restore you just performed. So, first, open the database READ ONLY, and view some data, to check whether the recovery did what you expected.

SQL> ALTER DATABASE OPEN READ ONLY;
4.   If satisfied with the results of the recovery, open the database with the RESETLOGS option, as shown:

SQL ALTER DATABASE OPEN RESETLOGS;