Wednesday, August 26, 2026

Why SAVE STATE is Required in Oracle PDB ?

In Oracle Multitenant architecture, SAVE STATE is a feature that allows a Pluggable Database (PDB) to remember its open mode across a CDB restart.

Without SAVE STATE, when the Container Database (CDB) is restarted, all PDBs (except PDB$SEED) typically remain in MOUNTED state and must be opened manually.


The PDB SAVE STATE feature was introduced in Oracle Database 12c Release 1 Patch Set 1 (12.1.0.2). Prior to 12.1.0.2, PDBs did not automatically return to their previous open state after a CDB restart, and DBAs commonly used startup triggers to open PDBs automatically.

For Oracle 19c/21c/23ai/26ai, this feature remains widely used and is considered the standard method for automatic PDB startup.

Why SAVE STATE is Required

Suppose you have:

SQL> ALTER PLUGGABLE DATABASE PDBPROD OPEN;

PDBPROD is open and users can connect.

After a database restart:

SHUTDOWN IMMEDIATE;
STARTUP;

You may find:

SHOW PDBS;

Output:

PDB Name Open Mode
----------- ----------
PDB$SEED READ ONLY
PDBPROD MOUNTED

Applications cannot connect until you manually open the PDB.

To avoid this, Oracle provides SAVE STATE.


How to Save PDB State

Open the PDB first:

ALTER PLUGGABLE DATABASE PDBPROD OPEN;

Save its current state:

ALTER PLUGGABLE DATABASE PDBPROD SAVE STATE;

Oracle stores this information internally.


Verify Saved State

Query:

SELECT con_name,
state
FROM dba_pdb_saved_states;

Example:

CON_NAME STATE
--------- -----
PDBPROD OPEN


After CDB Restart

SHUTDOWN IMMEDIATE;
STARTUP;

Check:

SHOW PDBS;

Output:

PDB Name Open Mode
----------- ----------
PDB$SEED READ ONLY
PDBPROD READ WRITE

The PDB automatically opens because Oracle remembered the saved state.


Save State for All PDBs

ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Very useful after patching or maintenance.


Discard Saved State

If you don't want Oracle to auto-open a PDB:

ALTER PLUGGABLE DATABASE PDBPROD DISCARD STATE;

Verify:

SELECT * FROM DBA_PDB_SAVED_STATES;

The entry will be removed.


Save Different Open Modes

Read Write

ALTER PLUGGABLE DATABASE PDBPROD OPEN READ WRITE;
ALTER PLUGGABLE DATABASE PDBPROD SAVE STATE;

Read Only

ALTER PLUGGABLE DATABASE REPORT_PDB OPEN READ ONLY;
ALTER PLUGGABLE DATABASE REPORT_PDB SAVE STATE;
``

After restart, Oracle restores the same mode.


Check Current and Saved State

Current state:

SHOW PDBS;

or

SELECT name, open_mode
FROM v$pdbs;

Saved state:

SELECT con_id,
con_name,
instance_name,
state
FROM dba_pdb_saved_states;


RAC Environment

In Oracle RAC, SAVE STATE is instance-specific.

Example:

ALTER PLUGGABLE DATABASE PDBPROD OPEN INSTANCES=ALL;
ALTER PLUGGABLE DATABASE PDBPROD SAVE STATE INSTANCES=ALL;

Check:

SELECT con_name,
instance_name,
state
FROM dba_pdb_saved_states;

You will see an entry for each RAC instance.


Best Practice

After:

  • Creating a new PDB
  • Cloning a PDB
  • Refreshable PDB setup
  • Database patching
  • Migration to a new server

Always execute:

ALTER PLUGGABLE DATABASE ALL SAVE STATE;

and verify:

SELECT con_name, state
FROM dba_pdb_saved_states;

This ensures all required PDBs automatically open after any database restart and avoids application outages caused by PDBs remaining mounted.

No comments:

Post a Comment

what is catcon.pl (Catalog Container Script) and why very useful for Oracle Multitenant Database ?

  catcon.pl (Catalog Container Script) is an Oracle utility introduced with the Multitenant Architecture (CDB/PDB) to execute SQL scripts ...