Database 12c: Get back from PDB to Non-CDB


I’vh written many articles about converting a Non-CDB to a PDB. I’m going to check the way back to a Non-CDB now.

First check what a convert to PDB is. The plug-in process of a Non-CDB consists of two parts:

  1. (PHYSICAL) Migration of the necessary datafiles
  2. (LOGICAL) Conversion of the data dictionary with the noncdb_to_pdb.sql script

How it works?

“The non-CDB’s datafiles, together with the manually created manifest, can now be treated as
if they were an ordinarily unplugged PDB and simply plugged in to the target CDB and
opened as a PDB. However, as will be explained immediately, it must be opened with the
Restricted status set to YES. The tablespaces holding quota-consuming data are immediately
viable, just as if this had been a Data Pump import using transportable tablespaces. However,
the former non-CDB’s data dictionary so far has a full description of the Oracle system. This
is now superfluous, and so it must simply be removed. While still with the Restricted status set
to YES, the noncdb_to_pdb.sql script (found on the admin_directory under Oracle Home) must be
run. Now the PDB may be closed and then opened ordinarily.” –> Found here

The seconds step make all physical revert step impossible, because there is datafile 1 or real SYSTEM tablespace any more. These steps are:

  1. RMAN Full or Point-in-time-recovery will restore the whole CDB and not only the PDB. Further this is no PDB to Non-CDB conversion
  2. Transportable Database is not usable because datafile 1 is not the real SYSTEM tablespace

All in all the root problem is, that no datafile 1 or independent SYSTEM tablespace exists any more.

And now the ways to get back:

  1. Transportable Tablespace (this is the smoothest way)
  2. DataPump full export/import
  3. Other logical migration ways like Oracle GoldenGate

I’vh tested old export tool (exp) too, but exporting a PDB will end with the error “EXP-00062: invalid source statements for an object type”

If there are more ways I will appreciate a comment 🙂

Database 12c: Duplicate PDB


Today morning I wanted to check how to duplicate a PDB. The first questions to me were:

  • Duplicate PDB, how to create an empty PDB and bring it to nomount like non-cdbs?
  • Duplicate within a CDB?

Here the answer:

The duplication process of a PDB works at CDB level. So if you want to duplicate a PDB you have to create an empty CDB instance. Then the needed parts of the CDB will be cloned and all other dropped. This will answer the second question: duplication within a CDB is not out-of-the-box possible. But you are able to clone the PDB or use a shadow CDB.

Here the example to clone:

Setup:

  • Target CDB = CDB12C1
  • Auxiliary CDB = CDB12C3
  • PDB to duplicate = Only PDB1
[bash]$ rman target sys/<password>@cdb12c1 auxiliary sys/<password>@cdb12c3

Recovery Manager: Release 12.1.0.1.0 - Production on Sat Jul 20 13:15:57 2013

Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

connected to target database: CDB12C1 (DBID=2076797181)
connected to auxiliary database: CDB12C3 (not mounted)

RMAN> duplicate target database to CDB12C3 pluggable database pdb1 from active database;

Starting Duplicate Db at 20-JUL-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=5 device type=DISK
current log archived

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''CDB12C1'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''CDB12C3'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'cdb12c1' primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''CDB12C1'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''CDB12C3'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     417546240 bytes

Fixed Size                     2289064 bytes
Variable Size                293601880 bytes
Database Buffers             113246208 bytes
Redo Buffers                   8409088 bytes

Starting restore at 20-JUL-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=5 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/oracle/app/oradata/CDB12C3/control01.ctl
Finished restore at 20-JUL-13

database mounted
Skipping pluggable database PDB2
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace UNDOTBS1
Skipping tablespace USERS

contents of Memory Script:
{
   set newname for clone datafile  1 to new;
   set newname for clone datafile  3 to new;
   set newname for clone datafile  4 to new;
   set newname for clone datafile  5 to new;
   set newname for clone datafile  7 to new;
   set newname for clone datafile  21 to new;
   set newname for clone datafile  22 to new;
   restore
   from service  'cdb12c1'   clone database
   skip forever tablespace  "USERS",
 "PDB2":"SYSTEM",
 "PDB2":"SYSAUX"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 20-JUL-13
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00021 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00022 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 20-JUL-13

sql statement: alter system archive log current
current log archived

contents of Memory Script:
{
   restore clone force from service  'cdb12c1' 
           archivelog from scn  2534976;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 20-JUL-13
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=97
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cdb12c1
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=98
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 20-JUL-13

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwdjk0_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwdqkh_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_undotbs1_8ynwdynw_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=13 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwf5kv_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=14 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwf8lz_.dbf
datafile 21 switched to datafile copy
input datafile copy RECID=15 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwfhny_.dbf
datafile 22 switched to datafile copy
input datafile copy RECID=16 STAMP=821279836 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwflo0_.dbf

contents of Memory Script:
{
   set until scn  2535061;
   recover
   clone database
   skip forever tablespace  "USERS",
 "PDB2":"SYSTEM",
 "PDB2":"SYSAUX"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20-JUL-13
using channel ORA_AUX_DISK_1

Executing: alter database datafile 6 offline drop
Executing: alter database datafile 23 offline drop
Executing: alter database datafile 24 offline drop
starting media recovery

archived log for thread 1 with sequence 97 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C3/archivelog/2013_07_20/o1_mf_1_97_8ynwft7h_.arc
archived log for thread 1 with sequence 98 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C3/archivelog/2013_07_20/o1_mf_1_98_8ynwfv8y_.arc
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C3/archivelog/2013_07_20/o1_mf_1_97_8ynwft7h_.arc thread=1 sequence=97
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C3/archivelog/2013_07_20/o1_mf_1_98_8ynwfv8y_.arc thread=1 sequence=98
media recovery complete, elapsed time: 00:00:00
Finished recover at 20-JUL-13
Oracle instance started

Total System Global Area     417546240 bytes

Fixed Size                     2289064 bytes
Variable Size                293601880 bytes
Database Buffers             113246208 bytes
Redo Buffers                   8409088 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''CDB12C3'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
}
executing Memory Script

sql statement: alter system set  db_name =  ''CDB12C3'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile
Oracle instance started

Total System Global Area     417546240 bytes

Fixed Size                     2289064 bytes
Variable Size                293601880 bytes
Database Buffers             113246208 bytes
Redo Buffers                   8409088 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CDB12C3" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1  SIZE 50 M ,
  GROUP   2  SIZE 50 M ,
  GROUP   3  SIZE 50 M 
 DATAFILE
  '/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwdjk0_.dbf',
  '/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwf5kv_.dbf',
  '/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_system_8ynwfhny_.dbf'
 CHARACTER SET AL32UTF8

contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   set newname for clone tempfile  2 to new;
   set newname for clone tempfile  3 to new;
   switch clone tempfile all;
   catalog clone datafilecopy  "/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwdqkh_.dbf", 
 "/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_undotbs1_8ynwdynw_.dbf", 
 "/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwf8lz_.dbf", 
 "/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwflo0_.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 2 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_temp_%u_.tmp in control file

cataloged datafile copy
datafile copy file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwdqkh_.dbf RECID=1 STAMP=821279854
cataloged datafile copy
datafile copy file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_undotbs1_8ynwdynw_.dbf RECID=2 STAMP=821279854
cataloged datafile copy
datafile copy file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwf8lz_.dbf RECID=3 STAMP=821279854
cataloged datafile copy
datafile copy file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwflo0_.dbf RECID=4 STAMP=821279854

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=821279854 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwdqkh_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=821279854 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_undotbs1_8ynwdynw_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=3 STAMP=821279854 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwf8lz_.dbf
datafile 22 switched to datafile copy
input datafile copy RECID=4 STAMP=821279854 file name=/opt/oracle/app/oradata/CDB12C3/datafile/o1_mf_sysaux_8ynwflo0_.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Executing: drop pluggable database "PDB2"

contents of Memory Script:
{
   sql clone "alter pluggable database all open";
}
executing Memory Script

sql statement: alter pluggable database all open
Dropping offline and skipped tablespaces
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Finished Duplicate Db at 20-JUL-13

RMAN>

Now check the new PDB

SQL> select * from v$pdbs

    CON_ID       DBID    CON_UID GUID                             NAME                           OPEN_MODE  RES OPEN_TIME                                                                   CREATE_SCN TOTAL_SIZE
---------- ---------- ---------- -------------------------------- ------------------------------ ---------- --- --------------------------------------------------------------------------- ---------- ----------
         2 4063775335 4063775335 E1E189D14D2C2049E0430100007FAB5B PDB$SEED                       READ ONLY  NO  20-JUL-13 01.17.36.174 PM                                                      1720752  283115520
         3 3328955419 3328955419 E1EE338E12A16C3EE0430100007F1A4F PDB1                           READ WRITE NO  20-JUL-13 01.17.39.820 PM                                                      2502055  283115520

SQL> 

Important to know is that the GUID of the PDB doesn’t change in the new CDB.

Database 12c: RMAN Backup & Recovery of pluggable databases


RMAN Backup and Recovery operation have to be done at CDB level. For RMAN a PDB is just a bunch of datafiles.

Notice: If you want to restore a PDB from another CDB you have to restore the other CDB before and do an unplug an plug to transfer.

1. Backup of a PDB

RMAN> backup pluggable database pdb1 plus archivelog;
Starting backup at 11-JUL-13
 current log archived
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting archived log backup set
 channel ORA_DISK_1: specifying archived log(s) in backup set
 input archived log thread=1 sequence=19 RECID=1 STAMP=820531423
 input archived log thread=1 sequence=20 RECID=2 STAMP=820531461
 input archived log thread=1 sequence=21 RECID=3 STAMP=820532613
 input archived log thread=1 sequence=22 RECID=4 STAMP=820532651
 input archived log thread=1 sequence=23 RECID=5 STAMP=820532930
 input archived log thread=1 sequence=24 RECID=6 STAMP=820533638
 input archived log thread=1 sequence=25 RECID=7 STAMP=820534921
 input archived log thread=1 sequence=26 RECID=8 STAMP=820535377
 channel ORA_DISK_1: starting piece 1 at 11-JUL-13
 channel ORA_DISK_1: finished piece 1 at 11-JUL-13
 piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/backupset/2013_07_11/o1_mf_annnn_TAG20130711T222937_8xy5fkdh_.bkp tag=TAG20130711T222937 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 Finished backup at 11-JUL-13
Starting backup at 11-JUL-13
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting full datafile backup set
 channel ORA_DISK_1: specifying datafile(s) in backup set
 input datafile file number=00050 name=/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf
 input datafile file number=00049 name=/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_system_8xy5bq9w_.dbf
 channel ORA_DISK_1: starting piece 1 at 11-JUL-13
 channel ORA_DISK_1: finished piece 1 at 11-JUL-13
 piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/E1433B62351A0F0DE0430100007F3E51/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T222938_8xy5flmr_.bkp tag=TAG20130711T222938 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
 Finished backup at 11-JUL-13
Starting backup at 11-JUL-13
 current log archived
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting archived log backup set
 channel ORA_DISK_1: specifying archived log(s) in backup set
 input archived log thread=1 sequence=27 RECID=9 STAMP=820535385
 channel ORA_DISK_1: starting piece 1 at 11-JUL-13
 channel ORA_DISK_1: finished piece 1 at 11-JUL-13
 piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/backupset/2013_07_11/o1_mf_annnn_TAG20130711T222945_8xy5fsxz_.bkp tag=TAG20130711T222945 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 Finished backup at 11-JUL-13
Starting Control File and SPFILE Autobackup at 11-JUL-13
 piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/autobackup/2013_07_11/o1_mf_s_820535387_8xy5fvdw_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 11-JUL-13

As you can see is a backup of an PDB just a backup of the datafiles and the CDB archivelogs.

2. Full Restore & Recover of PDBs

RMAN> alter pluggable database pdb1 close;

Statement processed

RMAN> run {
2> restore pluggable database pdb1;
3> recover pluggable database pdb1;
4> }

Starting restore at 11-JUL-13
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00049 to /opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_system_8xy5bq9w_.dbf
channel ORA_DISK_1: restoring datafile 00050 to /opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/app/fast_recovery_area/CDB12C/E1433B62351A0F0DE0430100007F3E51/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T222938_8xy5flmr_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/E1433B62351A0F0DE0430100007F3E51/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T222938_8xy5flmr_.bkp tag=TAG20130711T222938
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 11-JUL-13

Starting recover at 11-JUL-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 11-JUL-13

RMAN> alter pluggable database pdb1 open;

Statement processed

RMAN>

3. PDB Point in time Recovery (PITR)

PDB PITR is in real mutible Tablespace  point-in-time recovery (TPITR). RMAN is triggering the PITR transparently. After all you have to open the pdb with “alter pluggable database open resetlogs“.

RMAN> alter pluggable database pdb1 close;

Statement processed

RMAN> run {
2> set until time "to_date('23:00 11-07-2013','hh24:mi dd-mm-yyyy')";
3> restore pluggable database pdb1;
4> recover pluggable database pdb1;
5> }

executing command: SET until clause

Starting restore at 11-JUL-13
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00049 to /opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_system_8xy5bq9w_.dbf
channel ORA_DISK_1: restoring datafile 00050 to /opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/app/fast_recovery_area/CDB12C/E1433B62351A0F0DE0430100007F3E51/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T222938_8xy5flmr_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/E1433B62351A0F0DE0430100007F3E51/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T222938_8xy5flmr_.bkp tag=TAG20130711T222938
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 11-JUL-13

Starting recover at 11-JUL-13
current log archived
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='qzgF'

initialization parameters used for automatic instance:
db_name=CDB12C
db_unique_name=qzgF_pitr_pdb1_CDB12C
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/opt/oracle/app
#No auxiliary destination in use
enable_pluggable_database=true
_clone_one_pdb_recovery=true
control_files=/opt/oracle/app/fast_recovery_area/CDB12C/controlfile/o1_mf_8xy7pxl8_.ctl
#No auxiliary parameter file used

starting up automatic instance CDB12C

Oracle instance started

Total System Global Area 1068937216 bytes

Fixed Size 2296576 bytes
Variable Size 293602560 bytes
Database Buffers 767557632 bytes
Redo Buffers 5480448 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until time "to_date('23:00 11-07-2013','hh24:mi dd-mm-yyyy')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
}
executing Memory Script

executing command: SET until clause

Starting restore at 11-JUL-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /opt/oracle/app/fast_recovery_area/CDB12C/autobackup/2013_07_11/o1_mf_s_820535387_8xy5fvdw_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/autobackup/2013_07_11/o1_mf_s_820535387_8xy5fvdw_.bkp tag=TAG20130711T222947
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/oracle/app/fast_recovery_area/CDB12C/controlfile/o1_mf_8xy7pxl8_.ctl
Finished restore at 11-JUL-13

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until time "to_date('23:00 11-07-2013','hh24:mi dd-mm-yyyy')";
# switch to valid datafilecopies
switch clone datafile 49 to datafilecopy 
 "/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_system_8xy5bq9w_.dbf";
switch clone datafile 50 to datafilecopy 
 "/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 1 to 
 "/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_system_8xy7qcfz_.dbf";
set newname for datafile 4 to 
 "/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_undotbs1_8xy7qch4_.dbf";
set newname for datafile 3 to 
 "/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_sysaux_8xy7qcj0_.dbf";
set newname for datafile 6 to 
 "/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_users_8xy7qkcn_.dbf";
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 6;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

datafile 49 switched to datafile copy
input datafile copy RECID=7 STAMP=820537745 file name=/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_system_8xy5bq9w_.dbf

datafile 50 switched to datafile copy
input datafile copy RECID=8 STAMP=820537745 file name=/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 11-JUL-13
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_system_8xy7qcfz_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_undotbs1_8xy7qch4_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_sysaux_8xy7qcj0_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_users_8xy7qkcn_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/oracle/app/fast_recovery_area/CDB12C/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T214335_8xy2q7cg_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/oracle/app/fast_recovery_area/CDB12C/backupset/2013_07_11/o1_mf_nnndf_TAG20130711T214335_8xy2q7cg_.bkp tag=TAG20130711T214335
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 11-JUL-13

datafile 1 switched to datafile copy
input datafile copy RECID=13 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_system_8xy7qcfz_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=14 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_undotbs1_8xy7qch4_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=15 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_sysaux_8xy7qcj0_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=16 STAMP=820537761 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_users_8xy7qkcn_.dbf

contents of Memory Script:
{
# set requested point in time
set until time "to_date('23:00 11-07-2013','hh24:mi dd-mm-yyyy')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB1' "alter database datafile 
 49 online";
sql clone 'PDB1' "alter database datafile 
 50 online";
sql clone "alter database datafile 6 online";
# recover pdb
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "USERS" pluggable database 
 'PDB1' delete archivelog;
sql clone 'alter database open read only';
plsql <<<begin
 add_dropped_ts;
end; >>>;
plsql <<<begin
 save_pdb_clean_scn;
end; >>>;
# shutdown clone before import
shutdown clone abort
plsql <<<begin
 pdbpitr_inspect(pdbname => 'PDB1');
end; >>>;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 1 online

sql statement: alter database datafile 4 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 49 online

sql statement: alter database datafile 50 online

sql statement: alter database datafile 6 online

Starting recover at 11-JUL-13
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 22 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_22_8xy2rcsv_.arc
archived log for thread 1 with sequence 23 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_23_8xy3126w_.arc
archived log for thread 1 with sequence 24 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_24_8xy3q6bj_.arc
archived log for thread 1 with sequence 25 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_25_8xy4z91m_.arc
archived log for thread 1 with sequence 26 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_26_8xy5fk5j_.arc
archived log for thread 1 with sequence 27 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_27_8xy5fsrc_.arc
archived log for thread 1 with sequence 28 is already on disk as file /opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_28_8xy7pxf9_.arc
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_22_8xy2rcsv_.arc thread=1 sequence=22
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_23_8xy3126w_.arc thread=1 sequence=23
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_24_8xy3q6bj_.arc thread=1 sequence=24
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_25_8xy4z91m_.arc thread=1 sequence=25
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_26_8xy5fk5j_.arc thread=1 sequence=26
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_27_8xy5fsrc_.arc thread=1 sequence=27
archived log file name=/opt/oracle/app/fast_recovery_area/CDB12C/archivelog/2013_07_11/o1_mf_1_28_8xy7pxf9_.arc thread=1 sequence=28
media recovery complete, elapsed time: 00:00:07
Finished recover at 11-JUL-13

sql statement: alter database open read only

Oracle instance shut down

Removing automatic instance
Automatic instance removed
auxiliary instance file /opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_sysaux_8xy7qcj0_.dbf deleted
auxiliary instance file /opt/oracle/app/fast_recovery_area/CDB12C/controlfile/o1_mf_8xy7pxl8_.ctl deleted
Finished recover at 11-JUL-13

RMAN> alter pluggable database pdb1 open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 07/11/2013 23:09:38
ORA-01113: file 50 needs media recovery
ORA-01110: data file 50: '/opt/oracle/app/oradata/CDB12C/E1433B62351A0F0DE0430100007F3E51/datafile/o1_mf_sysaux_8xy5brt3_.dbf'

RMAN> alter pluggable database pdb1 open resetlogs;

Statement processed

RMAN>

Per default “Fast Recovery Area” is used for auxiliary datafiles, if FRA is configured.

datafile 1 switched to datafile copy
input datafile copy RECID=13 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_system_8xy7qcfz_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=14 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_undotbs1_8xy7qch4_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=15 STAMP=820537760 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_sysaux_8xy7qcj0_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=16 STAMP=820537761 file name=/opt/oracle/app/fast_recovery_area/CDB12C/datafile/o1_mf_users_8xy7qkcn_.dbf

If there is not enough space it is possible to use another storage area:

recover pluggable database pdb1 auxiliary destination='/stage/pdb1';