• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to create restore points for PDB and perform flashback at PDB level

by admin

This post discusses how to create restore points for PDB and perform flashback at PDB level which is introduced from 12.2. For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:

PDB Name: PDB1
Restore Point: TEST1
Restore Point (Guarantee) TEST2

1. Creating restore points at PDB level

Connect to the specific PDB and then run CREATE RESTORE POINT command:

SQL> alter session set container=PDB1;
SQL> create restore point TEST1;
SQL> create restore point TEST2 guarantee flashback database;

or

Connect to the CDB and use FOR PLUGGABLE DATABASE clause of CREATE RESTORE POINT command:

SQL> alter session set container=CDB$ROOT;
SQL> create restore point TEST1 for pluggable database PDB1;
SQL> create restore point TEST2 for pluggable database PDB1 guarantee flashback database;

Note: Starting from 12.2, we have the option to create Multitenant Databases with Local Undo. This means that each PDB uses it’s own UNDO tablespace. In such a PDB setup, a flashback operation at PDB level can rollback changes made to the PDB’s Undo tablespace similar to system, sysaux or user tablespaces of that PDB i.e. there is no dependency with the CDB or other PDB’s.

However, if your 12.2 Multitenant Database is still using Shared Undo, in such a setup, the UNDO tablespace is shared among all PDB’s. So, if a flashback operation is performed at PDB level, we need to use AUXILIARY DESTINATION clause along with FLASHBACK PLUGGABLE DATABASE command. This is used to create a auxiliary instance where CDB’s system,sysaux and undo are restored till the point-in-time of flashback to rollback the active transactions in that particular PDB whose flashback is being performed. To avoid having to create this auxiliary instance during flashback of PDB that uses Shared Undo, you can optionally create a clean restore point with the PDB closed. When doing PDB flashback to a clean restore point, auxiliary instance need not be created since there would be no active transactions in the PDB as of the time of restore point:

SQL> alter pluggable database PDB1 close;
SQL> create clean restore point Before_Upgrade for pluggable database PDB1;

2. Viewing restore-point information

View the restore-point information either via SQL*PLUS or RMAN:

SQL> select NAME,TIME,SCN,PDB_RESTORE_POINT,GUARANTEE_FLASHBACK_DATABASE from V$RESTORE_POINT;

NAME            TIME                                  SCN        PDB GUA
--------------- ------------------------------------- ---------- --- ---
TEST2 09-AUG-17 12.42.53.000000000 PM                 1451338    YES YES
TEST1 09-AUG-17 12.42.21.000000000 PM                 1451318    YES NO
RMAN> list restore point all;

SCN              RSP                  Time Type    Time                 Name
---------------- -------------------- ------------ -------------------- ----
1451318                               09-AUG-2017  12:42:21             TEST1
1451338          GUARANTEED           09-AUG-2017  12:42:53             TEST2

3. Performing flashback

a. If PDB uses local undo:

SQL> alter pluggable database PDB1 close;
SQL> flashback pluggable database PDB1 to restore point TEST1;
SQL> alter pluggable database PDB1 open resetlogs;

b. If PDB uses shared undo and restore point created when PDB was open:

RMAN> alter pluggable database PDB1 close;
RMAN> flashback pluggable database PDB1 to restore point TEST1 auxiliary destination '/o122/app/oracle/oradata/stage';
RMAN> alter pluggable database PDB1 open resetlogs;

c. If PDB uses shared undo and restore point created when PDB was closed (i.e. clean restore point)

SQL> alter pluggable database PDB1 close;
SQL> flashback pluggable database PDB1 to clean restore point TEST1;
SQL> alter pluggable database PDB1 open resetlogs;

Filed Under: oracle, oracle 12c

Some more articles you might also be interested in …

  1. How to find daily and hourly archive log generation in Oracle Database
  2. Oracle ASM : Shell script to map physical disk devices to ASMLIB disks
  3. Oracle Database Environment Variables and Their Functions
  4. How to move a Datafile to a different Location on a Physical Standby Database
  5. Simple Steps to use LogMiner for finding high redo log generation
  6. How to Use Udev Rules to Create oracleasm Disks in CentOS/RHEL 8
  7. Beginners Guide to Oracle Temporary Tablespaces
  8. Oracle Database – How to Rename a Datafile with Special Characters Created by Mistake
  9. How to Verify if a Disk/Partition is in Use by Oracle ASM, was used by Oracle ASM or is never used by Oracle ASM
  10. Oracle SQL script to Show current Users and SQL being Executed

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright