I. HOW TO CONFIGURE FLASHBACK DATABASE?

1. Before to configure Flashback Database, you must ensure that:  Your database is running in ARCHIVELOG mode  FRA (Flash Recovery Area) is configured  FRA is configured by two parameters: o DB_RECOVERY_FILE_DEST o DB_RECOVERY_FILE_DEST_SIZE  COMPATIBILITY initialization parameter is set to 10.0 or higher value 2. Consider the value for flashback database window. It can be set by an initialization parameter: DB_FLASHBACK_RETENTION_TARGET. The range of SCNs for which there is currently enough flashback log data to support the FLASHBACK DATABASE command is called the Flashback Database Window. The flashback window depends of the current environment requirement but usually it can be between 24 and 72 hours. Don’t consider too big values for flashback window because if you need to perform flashback database operation to a point in time older than several days it can be slower and much more time-consuming operation than using of media recovery method. Note: The flashback retention target is not an absolute guarantee that flashback will be available. If space is needed for required files in the Flash Recovery Area, flashback logs may be deleted automatically. So Flashback Database is efficient and fast for smaller time spans when the error is immediately (or within few hours) discovered and performing of a Database Point-in-Time Recovery is the only one way to recover from this human error. Default value for DB_FLASHBACK_RETENTION_TARGET is 1440. It is measured in minutes, so by default flashback window is 24 hours. Keep in mind that flashback logs use additional space within the FRA and we can restore up to the available Flashback logs. Note: Flashback Database logs are not archived. Rather the file is backed up to tape. 3. Connect as user SYS with SYSDBA privileges. 4. Check the Database Archive mode. SQL> ARCHIVE LOG LIST Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 4 Next log sequence to archive 6 Current log sequence 6 5. Configure DB_FLASHBACK_RETENTION_TARGET: DB_RECOVERY_FILE_DEST:

2. you can use this feature by issuing of the SQL command FLASHBACK DATABASE statement. you can use a restore point or a time just before last RESETLOGS operation. SQL> STARTUP MOUNT For RAC environments. you can do this in few steps: 1. Find the current oldest SCN and time to which the database can be backwarded: . Usually it is the time just before the time when some human error caused a logical damage of the database data. To enable Flashback Database feature. Start the database in MOUNT stage. If there is an event (human error) that insists the database to be flashed back to a point in time.  In SQL*Plus. Open the database with enabled Flashback Database feature: SQL> ALTER DATABASE OPEN. use: SQL> STARTUP MOUNT EXCLUSIVE 8.DB_RECOVERY_FILE_DEST_SIZE SQL> ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=1440 SCOPE=BOTH. A Log Sequence Number can be used in 10g R1 but it is not available as an option in 10g R2 (via SQL*Plus). Shut down the database: SQL> SHUTDOWN IMMEDIATE 7. 3. It is still available as an option in RMAN. Additionally. Creating guaranteed restore point. II.  In RMAN. SQL> CREATE RESTORE POINT TESTING1_2013_NOV_16_01_38 GUARANTEE FLASHBACK DATABASE. 6. Find the desired point in time for the flashback operation. You can calculate this as SCN or a Date (TIMESTAMP expression). The Flashback Database is useful only when your data is logically corrupted. SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE=1260G SCOPE=BOTH. SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST= ’+disk_flash’ SCOPE=BOTH. 9. your database must be in MOUNT mode. 11. Check whether the Flashback Database feature is enabled or not: SQL> SELECT flashback_on FROM V$DATABASE. you can use this feature by issuing of the command FLASHBACK. USING OF FLASHBACK DATABASE TO GUARANTEED RESTORE POINT Database can be flashed back either through SQL*Plus or RMAN. Enable Flashback Database Feature: SQL> ALTER DATABASE FLASHBACK ON. Ensure that you are not dealing with some kind of media failure. 10.

OLDEST_FLASHBACK_SCN TO_CHAR(OLDEST_FLASH --------------------------------------367953910842 16-11-2013::01:35:48 5. flashback_on fb_logging.to_char(oldest_flashback_time.2 Find the current oldest SCN and time to which the database can be backwarded based on the available flashback logs. go to the next step. .dba_data_files WHERE NAME=tablespace_name. TIME.37. GUARANTEE_FLASHBACK_DATABASE. which is not the scope of this document.47. Otherwise.oldest_flashback_time FROM v$flashback_database_log. STORAGE_SIZE FROM V$RESTORE_POINT WHERE GUARANTEE_FLASHBACK_DATABASE='YES' . 5. SQL> col scn form 9999999999999999 SQL> SELECT NAME. Ensure that all needed archived and redo logs (covering the whole time period between oldest_flashback_time column value and the time of failure or the restore point) are available: 5. file_name db_file. NAME SCN TIME DATABASE_INCAR# GUA STORAGE_SIZE -----------------------------------------------------------------------------------------------------TESTING1_2013_NOV_16_01_38 367953911831 16-NOV-13 01. If there are files with no important data that are excluded from flashback logging then you can follow Dealing with Excluded Tablespaces in case of Flashback Database Operations. DATABASE_INCARNATION#.SQL> SELECT oldest_flashback_scn.000000000 AM 2 YES 9663676416 5. If the desired time is after the oldest time currently recorded in the flashback log files then go to the next step 4.1 Check the Guaranteed Restore point availability. SCN.'DD-MM-YYYY::HH24:MI:SS') FROM v$flashback_database_log. online_status status FROM v$tablespace.3 Check physical availability of archives using RMAN: RMAN> CROSSCHECK ARCHIVELOG FROM SCN oldest_flashback_scn. SQL> SELECT oldest_flashback_scn. Ensure that there are not tablespaces with disabled flashback logging: SQL> SELECT NAME tbs_name.

you can use the built-in SQL functions (available since 10g): SCN_TO_TIMESTAMP – to find associated timestamp with this SCN TIMESTAMP_TO_SCN – to find associated SCN with this timestamp SQL> SELECT current_scn. SQL> SELECT current_scn FROM v$database. REPORT UNRECOVERABLE command reports all datafiles that cannot be recovered from existing backups because redo may be missing.1 SQL> SHUTDOWN IMMEDIATE 7. Find and write down the current SCN (or create a normal restore point if you are using 10g R2). Where oldest_flashback_scn is the value of the column oldest_flashback_scn in V$FLASHBACK_DATABASE_LOG. Restart the database in MOUNT stage 7. scn_to_timestamp(current_scn) FROM v$database. or SQL> CREATE RESTORE POINT before_flashback_operation. You can check the logical availability of archived redo logs with the following SQL as well: SQL> SELECT * FROM v$archived_log WHERE first_change# > = oldest_flashback_scn AND status = 'A'. 7. This timestamp mapping information is recorded in the SMON_SCN_TIME table. Oracle keeps the information in SMON_SCN_TIME table for a period of 5 days. use: SQL> STARTUP MOUNT EXCLUSIVE If you want to be able to return the database to its state just as it was closed.2 SQL> STARTUP MOUNT For RAC environments. you can create a restore point at this moment (restore points can be created even in MOUNT stage): SQL> CREATE RESTORE POINT just_after_shutdown. To map a time value and SCN. Or to find the last checkpointed SCN: .Where oldest_flashback_scn is the value of the column oldest_flashback_scn in V$FLASHBACK_DATABASE_LOG. 6. 5.3 Check logical availability of archives using RMAN: RMAN> REPORT UNRECOVERABLE. Don’t forget that the Flashback Database is a change on the database and it must be recorded if some failure occurs during this operation.

1.05. 9. Creating Guaranteed restore point after completing flashback operation if required again. In RMAN it can be done by FLASHBACK command. SQL> CREATE RESTORE POINT TESTING1_2013_DEC_05_01_38 GUARANTEE FLASHBACK DATABASE. In the next step.3. Open the Database with OPEN RESETLOGS clause: SQL> ALTER DATABASE OPEN RESETLOGS. /* returns database to its state as in the point in time one hour ago */ 11. you will need the above SCN. 10. 8. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of SYSTIMESTAMP) SQL> FLASHBACK DATABASE TO TIMESTAMP (SYSTIMESTAMP -1/24). if you perform a few flashback operations and you need to return the database to its state just before to be closed.2006 15:10'.05.2006 15:10 */ 11. Flashes back the database to a point in time just as in the specified SCN: SQL> FLASHBACK DATABASE TO SCN 4125962274. For this example the point of time before the logical corruption is: As SCN: 4125962274 As Timestamp: 24. /* returns database to its state as in the point in time marked with SCN 4125962274 */ 11.yyyy hh24:mi').05.SQL> SELECT checkpoint_change# FROM v$database. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of custom TIMESTAMP value): SQL> FLASHBACK DATABASE TO TIMESTAMP to_timestamp('24.4. Flashes back the database to a point in time just as in the specified guaranteed restore point SQL> FLASHBACK DATABASE TO RESTORE POINT TESTING1_2013_NOV_16_01_38.2006 15:10 In SQL it can be done by FLASHBACK DATABASE command. Different types of Flashback the Database usage other than guaranteed RESTORE POINT.'dd.mm. 11. ---------------------------------------------X------------------------------X------------------------------ 11. Flashes back the database to a point in time just as in the specified TIMESTAMP (by using of SYSTIMESTAMP and INTERVAL): .2. /* returns database to its state as in the point in time 24.

'dd.SQL> FLASHBACK DATABASE TO TIMESTAMP (SYSTIMESTAMP .10. 11.6.05. If you use flashback features or point-in-time recovery. SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP (SYSTIMESTAMP . /* returns database to its state as in the point in time marked with the restore point with name before_flashback_operation */ 11. then you can use the name of the restore point instead of a time or SCN.INTERVAL '1' MINUTE). 11. RMAN> FLASHBACK DATABASE TO BEFORE RESETLOGS.mm. . RMAN> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation. 11. Flashes back the database to a point in time just as in the specified restore point SQL> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation.INTERVAL '1' MINUTE).8.'dd. Flashbacks the database to the point in time just before the last RESETLOGS operation SQL> FLASHBACK DATABASE TO BEFORE RESETLOGS. RMAN> FLASHBACK DATABASE TO TIMESTAMP to_timestamp('24. SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP (SYSDATE -1/24).2006 15:10'. /* returns database to its state as in the point in time one minute ago */ 11. Flashes back the database to a point in time just before the specified restore point SQL> FLASHBACK DATABASE TO BEFORE RESTORE POINT before_flashback_operation.mm. Flashes back the database to a SCN just before the specified SCN SQL> FLASHBACK DATABASE TO BEFORE SCN 4125962274. Flashing back of the database via RMAN RMAN> FLASHBACK DATABASE TO SCN 4125962274. RMAN> FLASHBACK DATABASE TO TIMESTAMP (SYSDATE-1/24).05.7. Flashes back the database to a point in time one second before the specified TIMESTAMP SQL> FLASHBACK DATABASE TO BEFORE TIMESTAMP to_timestamp('24. 11.9. RESTORE POINT Restore point can be normal restore point or Guaranteed Restore Points Normal restore point Creating a normal restore point assigns a restore point name to an SCN or specific point in time.5.yyyy hh24:mi').yyyy hh24:mi'). III.2006 15:10'.

If space is needed for required files in the Flash Recovery Area. this causes your database to halt. As the flashback retention target is not an absolute guarantee that flashback will be available. with or without enabling full flashback database logging. 1. When you create a guaranteed restore point. you must monitor the space available in your fast recovery area. can cause the fast recovery area to fill completely. 2. When you use the RMAN FLASHBACK DATABASE command. A guaranteed restore point enforces the retention of flashback logs required for Flashback Database to any SCN after the earliest guaranteed restore point. No file in the fast recovery area is eligible for deletion if it is required to satisfy a guaranteed restore point. flashback logs may be deleted automatically. Normal restore points eventually age out of the control file if not manually deleted. then an archived redo log that is reclaimable according to the fast recovery area rules may be automatically deleted by the fast recovery area to make space for other files. Creating Guaranteed restore point. Flashes back the database to a point in time just as in the specified restore point SQL> FLASHBACK DATABASE TO RESTORE POINT before_flashback_operation. Guaranteed Restore Points Like a normal restore point. archived redo logs required to satisfy a guaranteed restore point may be deleted after they are backed up to disk or tape.create a normal restore point SQL> CREATE RESTORE POINT before_flashback_operation. In many circumstances. A principal difference is that guaranteed restore points never age out of the control file and must be explicitly dropped. Retention of flashback logs and other files required to satisfy the guaranteed restore point. then the database performs as if it has encountered a disk full condition. if the archived redo logs required to satisfy a specified guaranteed restore point are not available in the fast recovery area. then they are restored from the backups. If no files are eligible for deletion from the fast recovery area because of the requirements imposed by your retention policy and the guaranteed restore point. We are using guaranteed restore point in TESTING1 Server. In this case. any flashback logs that would require the use of that redo log file for the use of FLASHBACK DATABASE to normal restore point are also deleted. in addition to files required to satisfy the backup retention policy. a guaranteed restore point serves as an alias for an SCN in recovery operations. If the fast recovery area is full. However. Check the availability of guaranteed restore point: . CREATE RESTORE POINT TESTING1_2013_DEC_05_01_38 GUARANTEE FLASHBACK DATABASE. so they require no ongoing maintenance.

SQL> col scn form 9999999999999999 SQL> SELECT NAME. DATABASE_INCARNATION#. NAME SCN TIME DATABASE_INCAR# GUA STORAGE_SIZE -----------------------------------------------------------------------------------------------------TESTING1_2013_NOV_16_01_38 367953911831 16-NOV-13 01. GUARANTEE_FLASHBACK_DATABASE. TIME.47.37. SCN. STORAGE_SIZE FROM V$RESTORE_POINT WHERE GUARANTEE_FLASHBACK_DATABASE='YES' .000000000 AM 2 YES 9663676416 .