Introduction
Managing Pluggable Databases (PDBs) in an Oracle Multitenant environment is relatively straightforward. However, when Oracle Data Guard is configured, even a simple operation such as dropping a PDB requires additional consideration.
One common question Oracle DBAs encounter is:
If we drop a Pluggable Database (PDB) from the Primary database, will Oracle automatically drop the same PDB from the Physical Standby database?
The answer depends on the Oracle Database version and, in certain releases, the open mode of the PDB on the standby database.
In Oracle Database 19c, redo apply can automatically handle PDB drop operations, including closing an open standby PDB when necessary. However, older 12c releases have additional considerations.
In this article, we'll perform a practical demonstration using Oracle Database 19c and Data Guard to understand what happens when a PDB is dropped from the primary database under two different standby configurations.
We'll cover:
How PDB drop operations propagate through redo.
What happens when the standby PDB is in MOUNTED mode.
What happens when the standby PDB is open in READ ONLY mode.
How MRP handles PDB drop markers.
How to troubleshoot ORA-65112.
Differences between Oracle 12c and 19c.
Manual recovery considerations for older releases.
1. Understanding the Lab Environment
For this demonstration, I'm using Oracle Database 19c with a Primary and Physical Standby configuration.
To make the example easy to follow, I've used separate CDB names, DB unique names, hostnames, and PDB names.
Data Guard Configuration
| Parameter | Primary | Physical Standby |
|---|---|---|
| Hostname | ora19c-pri01 | ora19c-stby01 |
| CDB Name | PRODDB | PRODDB |
| DB Unique Name | PRODDB | PRODDB_STBY |
| Database Role | PRIMARY | PHYSICAL STANDBY |
| Open Mode | READ WRITE | MOUNTED |
| Database Version | 19c | 19c |
PDB Configuration
Our primary database contains two application PDBs:
SALES_PDB
HR_PDB
We'll use SALES_PDB for our first test case and HR_PDB for the second test case.
The objective is to drop these PDBs from the primary database and observe how the standby database handles the corresponding redo operations.
2. Verify Primary and Standby Database Configuration
Let's first connect to the primary database.
SQL> SELECT
name,
db_unique_name,
open_mode,
database_role
FROM v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
------- --------------- ----------- ----------------
PRODDB PRODDB READ WRITE PRIMARYCheck the PDB configuration.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ---------- ---------- ----------
2 PDB$SEED READ ONLY NO
3 SALES_PDB READ WRITE NO
4 HR_PDB READ WRITE NONow connect to the physical standby database.
SQL> SELECT
name,
db_unique_name,
open_mode,
database_role
FROM v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
------- --------------- ---------- ----------------
PRODDB PRODDB_STBY MOUNTED PHYSICAL STANDBYCheck the standby PDB status.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED MOUNTED
3 SALES_PDB MOUNTED
4 HR_PDB MOUNTEDOur initial configuration is ready.
3. Verify Data Guard Redo Transport and Apply Status
Before performing any DDL operation on the primary database, we should verify that redo transport and apply are functioning correctly.
In Oracle 19c, we can use V$DATAGUARD_PROCESS to monitor Data Guard processes.
SQL> SELECT
name,
role,
action,
thread#,
sequence#
FROM v$dataguard_process;We should also verify the transport and apply lag.
SQL> SELECT
name,
value,
time_computed
FROM v$dataguard_stats
WHERE name IN (
'transport lag',
'apply lag',
'apply finish time'
);Ideally, both transport lag and apply lag should be zero or within the expected operational limits.
For this demonstration, let's assume redo transport and apply are synchronized.
4. Test Case 1: Dropping a PDB When the Standby PDB Is in MOUNTED Mode
In our first scenario, SALES_PDB is in MOUNTED mode on the physical standby database.
This is a straightforward scenario in which redo apply can process the PDB drop operation.
Step 1: Verify the Primary PDB Status
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED READ ONLY
3 SALES_PDB READ WRITE
4 HR_PDB READ WRITEBefore dropping the PDB, close it on the primary database.
SQL> ALTER PLUGGABLE DATABASE SALES_PDB CLOSE IMMEDIATE;
Pluggable database altered.Now drop the PDB, including its associated datafiles.
SQL> DROP PLUGGABLE DATABASE SALES_PDB INCLUDING DATAFILES;
Pluggable database dropped.Verify the remaining PDBs.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED READ ONLY
4 HR_PDB READ WRITESALES_PDB has now been successfully dropped from the primary database.
Step 2: Check the Standby Alert Log
Now switch to the physical standby database and monitor its alert log.
You should observe recovery-related messages indicating that Oracle is removing the PDB's associated datafiles and tablespaces.
Representative alert log messages:
SALES_PDB(3): Recovery deleting file from controlfile.
SALES_PDB(3): Deleted Oracle managed file ...
SALES_PDB(3): Recovery dropped tablespace 'USERS'
SALES_PDB(3): Recovery dropped tablespace 'SYSTEM'
SALES_PDB(3): Recovery dropped tablespace 'SYSAUX'
SALES_PDB(3): Recovery dropped pluggable database 'SALES_PDB'These messages indicate that the standby redo apply process has processed the PDB drop operation.
Step 3: Verify the Standby PDB Configuration
Connect to the physical standby database.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED MOUNTED
4 HR_PDB MOUNTEDSALES_PDB has automatically disappeared from the standby database.
Let's verify Data Guard apply status again.
SQL> SELECT
name,
value,
time_computed
FROM v$dataguard_stats
WHERE name IN (
'transport lag',
'apply lag'
);The standby database remains synchronized.
Observation: When the standby PDB is in MOUNTED mode, Oracle Database 19c automatically processes the PDB drop operation through redo apply. No manual PDB closure is required on the standby.
5. Test Case 2: Dropping a PDB When the Standby PDB Is Open in READ ONLY Mode
Now let's move to a more interesting scenario.
What happens if the PDB is open in READ ONLY mode on the physical standby database when the primary database drops it?
This scenario is particularly relevant for environments using Active Data Guard, where application reporting or read-only workloads run against the standby database.
We will use HR_PDB for this demonstration.
Step 1: Prepare the Physical Standby Database
For this demonstration, we need to open the physical standby database in READ ONLY mode.
Stop managed recovery first.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.Open the standby database.
SQL> ALTER DATABASE OPEN;
Database altered.Verify the database mode.
SQL> SELECT
name,
db_unique_name,
open_mode,
database_role
FROM v$database;
NAME DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
------- --------------- ---------- ----------------
PRODDB PRODDB_STBY READ ONLY PHYSICAL STANDBYNow open HR_PDB in READ ONLY mode.
SQL> ALTER PLUGGABLE DATABASE HR_PDB OPEN;
Pluggable database altered.Verify the PDB status.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED READ ONLY
4 HR_PDB READ ONLYRestart managed recovery.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE
DISCONNECT FROM SESSION;
Database altered.Note: This is an Active Data Guard scenario when the appropriate licensing and configuration are in place. Opening a physical standby read-only while managed recovery is stopped is not, by itself, the same as running Active Data Guard with real-time apply.
Step 2: Drop HR_PDB from the Primary Database
Switch to the primary database.
First, verify that HR_PDB is open.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED READ ONLY
4 HR_PDB READ WRITEClose the PDB.
SQL> ALTER PLUGGABLE DATABASE HR_PDB CLOSE IMMEDIATE;
Pluggable database altered.Drop it.
SQL> DROP PLUGGABLE DATABASE HR_PDB INCLUDING DATAFILES;
Pluggable database dropped.The PDB has now been removed from the primary database.
Step 3: Monitor the Standby Alert Log
Now switch to the standby database and examine the alert log.
In Oracle Database 19c, the recovery process can encounter the PDB drop marker while the standby PDB is still open.
Representative alert log messages may look like this:
PR00: MRP0: PDB unplug/drop/rename marker encountered.
PR00: Retry recovery...
ORA-65112: pluggable database HR_PDB
not closed on all instances of the standby databaseThis error indicates that the PDB must be closed before recovery can process the operation.
However, an important difference in Oracle 19c is that redo apply can automatically initiate the PDB closure.
You may subsequently observe messages similar to:
alter pluggable database "HR_PDB" close immediate
HR_PDB: Buffer Cache flush started
HR_PDB: Buffer Cache flush finished
Pluggable database HR_PDB closed
Completed: alter pluggable database "HR_PDB" close immediateAfter the PDB has been closed, recovery continues processing the drop operation.
Representative messages:
Managed Standby Recovery starting Real Time Apply
HR_PDB: Recovery dropped temporary tablespace 'TEMP'
HR_PDB: Recovery dropped tablespace 'SYSTEM'
HR_PDB: Recovery dropped tablespace 'SYSAUX'
HR_PDB: Recovery dropped pluggable database 'HR_PDB'The important observation here is that Oracle 19c can automatically close the affected standby PDB and continue redo apply.
You should always inspect the complete alert log to confirm that recovery resumed successfully rather than assuming that the initial ORA-65112 message represents a permanent failure.
Step 4: Verify the Standby Database
Let's check the standby PDB configuration.
SQL> SHOW PDBS;
CON_ID CON_NAME OPEN MODE
---------- ---------- ----------
2 PDB$SEED READ ONLYHR_PDB is no longer present.
Check the Data Guard process status.
SQL> SELECT
name,
role,
action,
thread#,
sequence#
FROM v$dataguard_process;Also verify transport and apply lag.
SQL> SELECT
name,
value,
time_computed
FROM v$dataguard_stats
WHERE name IN (
'transport lag',
'apply lag'
);The expected result is that managed recovery continues and the standby catches up with the primary.
Observation: In Oracle Database 19c, an open standby PDB does not necessarily require manual intervention for a PDB drop. Oracle can automatically close the PDB and continue redo apply.
6. What About Oracle Database 12c?
This is where database version becomes important.
In Oracle Database 12c, PDB drop and unplug operations could cause redo apply to stop when the corresponding PDB was open on the physical standby.
The behaviour depended on the release and patch level.
For Oracle Database 12.2.0.1, Oracle provided patch 25616359, which introduced improved handling of PDB drop and unplug operations during redo apply.
Without the relevant fix, DBAs may need to manually close the PDB on the standby before restarting managed recovery.
For example:
SQL> ALTER PLUGGABLE DATABASE HR_PDB CLOSE IMMEDIATE;If the environment is Oracle RAC, ensure the PDB is closed across all instances.
SQL> ALTER PLUGGABLE DATABASE HR_PDB
CLOSE IMMEDIATE INSTANCES=ALL;Then cancel the managed recovery process if it is still running or has entered an error state.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;If Data Guard Broker is managing the configuration, recovery can be controlled through DGMGRL.
DGMGRL> EDIT DATABASE 'PRODDB_STBY'
SET STATE='APPLY-OFF';
DGMGRL> EDIT DATABASE 'PRODDB_STBY'
SET STATE='APPLY-ON';Verify the managed recovery process and apply lag after restarting recovery.
Important: The exact recovery procedure should be selected according to the Oracle release, installed patches, standby open mode, RAC configuration, and Data Guard Broker configuration. Do not blindly execute these commands on a production standby.
7. Important Oracle DBA Considerations
Before dropping a PDB in a production Data Guard environment, keep the following points in mind.
1. Always verify the database role
Make sure you are connected to the correct primary database before executing a destructive operation.
SELECT name, db_unique_name, database_role
FROM v$database;2. Verify standby synchronization
Check transport lag and apply lag before performing the operation.
SELECT name, value
FROM v$dataguard_stats
WHERE name IN ('transport lag', 'apply lag');3. Check the standby PDB open mode
SELECT
name,
open_mode
FROM v$pdbs;4. Monitor the standby alert log
Do not rely exclusively on the SQL command response from the primary database. Verify that the standby has successfully processed the PDB drop marker.
5. Verify managed recovery
In Oracle 19c, prefer V$DATAGUARD_PROCESS for monitoring Data Guard processes.
6. Consider RAC environments
A PDB may be open on multiple standby instances. Ensure the PDB is closed on all relevant instances when manual intervention is required.
7. Understand the impact of INCLUDING DATAFILES
The command:
DROP PLUGGABLE DATABASE HR_PDB INCLUDING DATAFILES;removes the PDB and its associated datafiles. This is a destructive operation. Verify backups and recovery requirements before executing it.
8. Conclusion
So, does dropping a PDB from the primary database automatically drop it from the physical standby?
The answer is yes, provided redo transport and apply are functioning and the operation is supported by the relevant Oracle release and patch level.
Our Oracle 19c demonstration covered two scenarios:
| Scenario | Standby PDB State | Oracle 19c Behaviour |
|---|---|---|
| Test Case 1 | MOUNTED | PDB automatically dropped through redo apply |
| Test Case 2 | READ ONLY | Oracle can automatically close the PDB and continue redo apply |
For older Oracle 12c environments, the behaviour can be different, particularly when the standby PDB is open during the drop operation. The applicable release-specific fixes and recovery procedures must be considered.
Final takeaway: Before performing PDB lifecycle operations in a Data Guard environment, always consider the database version, patch level, standby PDB open mode, and managed recovery status. A successful DROP operation on the primary does not eliminate the need to verify redo apply on the standby.
Happy Learning & Happy DBAing!