Monday, January 28, 2013

Different recover scenario during incomplete database recovery

If you need to recover your database to a point in time by scn, sequence or time, you can use the following query to see the relation between time-scn-sequence, after restoring your database from a proper backup.

SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YY HH24:MI:SS';


SQL> select NAME, SEQUENCE#, FIRST_TIME, FIRST_CHANGE#, NEXT_TIME, NEXT_CHANGE# from v$archived_log where SEQUENCE# > 100;

NAME                                              SEQUENCE# FIRST_TIME        FIRST_CHANGE# NEXT_TIME         NEXT_CHANGE#
------------------------------------------------ ---------- ----------------- ------------- ----------------- ------------
D:\DATA\ARCHIVE\ARC00101_0800466637.001                 101 20-01-13 20:30:06       3982521 21-01-13 04:30:27      4011361
D:\DATA\ARCHIVE\ARC00102_0800466637.001                 102 21-01-13 04:30:27       4011361 21-01-13 19:47:21      4057937
D:\DATA\ARCHIVE\ARC00103_0800466637.001                 103 21-01-13 19:47:21       4057937 22-01-13 00:45:42      4080184
D:\DATA\ARCHIVE\ARC00104_0800466637.001                 104 22-01-13 00:45:42       4080184 22-01-13 09:00:30      4108498
D:\DATA\ARCHIVE\ARC00105_0800466637.001                 105 22-01-13 09:00:30       4108498 22-01-13 22:00:05      4150127
D:\DATA\ARCHIVE\ARC00106_0800466637.001                 106 22-01-13 22:00:05       4150127 23-01-13 03:40:58      4172819
D:\DATA\ARCHIVE\ARC00107_0800466637.001                 107 23-01-13 03:40:58       4172819 23-01-13 15:18:23      4211524
D:\DATA\ARCHIVE\ARC00108_0800466637.001                 108 23-01-13 15:18:23       4211524 23-01-13 15:22:48      4211829

8 rows selected.


You can modify the where clause depending on your needs. 

SEQUENCE# gives the sequence number of the archive log. FIRST_CHANGE# and NEXT_CHANGE# specify the first and last System Change Number (SCN); FIRST_TIME and NEXT_TIME specify the starting and ending time of that archivelog. Regarding to these information you can decide any of the following recover operations:

RMAN> recover database until sequence 107;
RMAN> recover database until SCN 4172819;
RMAN> recover database until time '23-01-13 03:40:58'

Or if you want to manually control recover process with specifying archive logs one by one, you can use "until cancel" clause in SQL. This recovery process continues until you cancel. If your archive logs are not on their default path you can specify the full path of the archive logs in this recovery process.

SQL > recover database until cancel;

No comments:

Post a Comment