Flashback in Oracle CDB and PDB

Flashback of Container Database (CDB)

The basic procedure for performing a flashback database operation on a container database (CDB) is the same as that for a non-CDB database.

$ sqlplus / as sysdba

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIMESTAMP SYSDATE-(5/24/60);
ALTER DATABASE OPEN RESETLOGS;

-- Open all pluggable databases.
ALTER PLUGGABLE DATABASE ALL OPEN;

Or the following in RMAN.

$ rman target=/

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO TIME 'SYSDATE-(5/24/60)';
ALTER DATABASE OPEN RESETLOGS;

# Open all pluggable databases.
ALTER PLUGGABLE DATABASE ALL OPEN;
Flashback in Oracle CDB and PDB

The basic procedure to flashback a CDB is as follows.

CONN / AS SYSDBA

SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
FLASHBACK DATABASE TO RESTORE POINT cdb1_before_changes;
ALTER DATABASE OPEN RESETLOGS;

-- Open all pluggable databases.
ALTER PLUGGABLE DATABASE ALL OPEN RESETLOGS;

The flashback operation itself can take one of several forms.

FLASHBACK DATABASE TO TIMESTAMP my_date;
FLASHBACK DATABASE TO BEFORE TIMESTAMP my_date;
FLASHBACK DATABASE TO SCN my_scn;
FLASHBACK DATABASE TO BEFORE SCN my_scn;
FLASHBACK DATABASE TO RESTORE POINT my_restore_point;

The flashback of a PDB varies depending on whether local undo mode is used or not. Typically, you will be using local undo mode, so the procedure will be as follows.

CONN / AS SYSDBA

ALTER PLUGGABLE DATABASE pdb1 CLOSE;
FLASHBACK PLUGGABLE DATABASE pdb1 TO RESTORE POINT pdb1_before_changes;
ALTER PLUGGABLE DATABASE pdb1 OPEN RESETLOGS;

The flashback operation itself can take one of several forms.

FLASHBACK PLUGGABLE DATABASE pdb1 TO TIMESTAMP my_date;
FLASHBACK PLUGGABLE DATABASE pdb1 TO BEFORE TIMESTAMP my_date;
FLASHBACK PLUGGABLE DATABASE pdb1 TO SCN my_scn;
FLASHBACK PLUGGABLE DATABASE pdb1 TO BEFORE SCN my_scn;
FLASHBACK PLUGGABLE DATABASE pdb1 TO RESTORE POINT my_restore_point;

If you are using shared undo mode, then the syntax is a little different as you will have to specify a location for an auxiliary instance.

FLASHBACK PLUGGABLE DATABASE my_pdb TO SCN my_scn AUXILIARY DESTINATION '/u01/aux';
FLASHBACK PLUGGABLE DATABASE my_pdb TO RESTORE POINT my_restore_point AUXILIARY DESTINATION '/u01/aux';
Flashback PDB Example

Create a restore point.

CONN / AS SYSDBA

CREATE RESTORE POINT pdb1_before_changes FOR PLUGGABLE DATABASE pdb1;