With the current release 12.2, flashback can be done on the PDB layer. As a prerequisite, the database must be put into local undo mode. That means that each PDB has its own undo tablespace. Some other 12.2 features like hot PDB cloning also require this, so chances are that most 12cR2 multitenant databases will be using that mode.
SQL> select banner from v$version; BANNER -------------------------------------------------------------------- Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Pr oduction PL/SQL Release 12.2.0.1.0 - Production CORE 12.2.0.1.0 Production TNS for Linux: Version 12.2.0.1.0 - Production NLSRTL Version 12.2.0.1.0 - Production SQL> select name,open_mode,con_id from v$pdbs; NAME OPEN_MODE CON_ID --------------- ---------- ------ PDB$SEED READ ONLY 2 PDB1 READ WRITE 3 SQL> select name,con_id from v$tablespace; NAME CON_ID --------------- ------ SYSAUX 1 SYSTEM 1 UNDOTBS1 1 USERS 1 TEMP 1 SYSTEM 2 SYSAUX 2 SYSTEM 3 TEMP 2 SYSAUX 3 TEMP 3 11 rows selected.
Initially, this database operates in what we call now shared undo mode: There is only one undo tablespace in the root container that is shared by all PDBs. Let’s change that to local undo mode:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade
ORACLE instance started.
Total System Global Area 1426063360 bytes
Fixed Size 8792776 bytes
Variable Size 486540600 bytes
Database Buffers 922746880 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.
SQL> alter database local undo on;
Database altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1426063360 bytes
Fixed Size 8792776 bytes
Variable Size 486540600 bytes
Database Buffers 922746880 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.
SQL> select name,con_id from v$tablespace;
NAME CON_ID
--------------- ------
SYSAUX 1
SYSTEM 1
UNDOTBS1 1
USERS 1
TEMP 1
SYSTEM 2
SYSAUX 2
SYSTEM 3
TEMP 2
SYSAUX 3
TEMP 3
UNDO_1 2
12 rows selected.
CON_ID 2 is the seed PDB, which got a local undo tablespace already. The pdb1 gets it as soon as it is opened:
SQL> alter pluggable database all open; SQL> select name,con_id from v$tablespace; NAME CON_ID ---------- ------ SYSAUX 1 SYSTEM 1 UNDOTBS1 1 USERS 1 TEMP 1 SYSTEM 2 SYSAUX 2 SYSTEM 3 TEMP 2 SYSAUX 3 TEMP 3 UNDO_1 2 UNDO_1 3 SQL> select name from v$datafile where con_id=3; NAME -------------------------------------------------------------------- /u02/app/oracle/oradata/pdb1/system01.dbf /u02/app/oracle/oradata/pdb1/sysaux01.dbf /u02/app/oracle/oradata/pdb1/pdb1_i1_undo.dbf
Now to the flashback!
SQL> select flashback_on from v$database; FLASHBACK_ON ------------------ YES SQL> alter pluggable database pdb1 close immediate; Pluggable database altered. SQL> flashback pluggable database pdb1 to timestamp systimestamp - interval '2' minute; Flashback complete. SQL> alter pluggable database pdb1 open resetlogs; Pluggable database altered.
Of course, that works much faster than a PDB PITR 🙂
#1 von Fayyaz am November 10, 2016 - 08:08
Nice new and much awaited feature as without this there was a hesitation to adopt the multi tenant architecture.
#2 von arcsdegeo am November 10, 2016 - 19:11
Very Nice Article, this feature was indeed needed with Multi-tenant Architecture in 12cR1
Thank you UWE
#3 von Carlos Roberto Reyes Matamoros am Juni 14, 2017 - 01:01
Excelent Article it helps me in my homework.