Posted on

Flashback Database

Flashback a Container or a Pluggable Database 1

This article contains scripts, which should be used for taking flashback restore points and restoring a pluggable database to these restore points (Doc ID 2308215.1).

  • The Container Database (CDB) is called CDB$ROOT.
  • The Pluggable Database (PDB) is called PDB.
  • The scripts are executed from sqlplus using SYS user.
Prerequisites
  • Archivelog turned ON2
  • Flashback turned ON3
Take a regular restore point on a live DATABASE
From the CDB
alter session set container=CDB$ROOT;
create restore point LIVE_RESTORE_POINT for pluggable database PDB guarantee flashback database;
From the PDB
alter session set container=PDB;
create restore point LIVE_RESTORE_POINT guarantee flashback database;


Restore PDB from a regular flashback restore point
alter session set container=CDB$ROOT;
alter pluggable database PDB close immediate instances=all;
flashback pluggable database PDB to restore point LIVE_RESTORE_POINT;
alter pluggable database PDB open resetlogs;


Take a clean flashback restore point on a Database which is shutdown (If PDB uses shared undo and restore point created when PDB was closed)
alter session set container=CDB$ROOT;
alter pluggable database PDB close immediate instances=all;
create clean restore point CLEAN_RESTORE_POINT for pluggable database PDB guarantee flashback database;
alter pluggable database PDB open instances=all;


Restore PDB from a clean flashback restore point
alter session set container=CDB$ROOT;
alter pluggable database PDB close immediate instances=all;
flashback pluggable database PDB to clean restore point CLEAN_RESTORE_POINT;
alter pluggable database PDB open resetlogs;


Notes:

When opening the PDB with RESETLOGS in the RAC environment, it can be executed with only one instance. Solution: Run ALTER PLUGGABLE DATABASE OPEN RESETLOGS without INSTANCES= clause.

Doc ID 2321868.1


  1. The script is proved to work with Oracle 12.2. 

  2. CONN / AS SYSDBA
    SHUTDOWN IMMEDIATE
    STARTUP MOUNT
    ALTER DATABASE ARCHIVELOG;
    ALTER DATABASE OPEN;
    

  3. SELECT flashback_on FROM v$database;
    ALTER DATABASE FLASHBACK ON;