Tag Archives: Retain Database PDB State

Check the Pluggable Database Saved State in Oracle

Pluggable Database Saved State in Oracle

Saved State is a feature in 12.1.0.2 for saved the OPEN state of all PDBS when CDB is restart. It will bring PDBs to same state if it open then it bring the PDB in Open State or if PDB is closed when CDB restart then it bring PDB in closed state. Open the database in READ-WRITE/READ-ONLY mode it save state.

Keyword SAVE STATE to preserve the PDBs’ mode when the CDB is restarted.
Keyword DISCARD STATE to ignore the PDBs’ open mode when the CDB is restarted.

Check the Save State for PDBS

select a.name,b.state from v$pdbs a , dba_pdb_saved_states b where a.con_id = b.con_id;

SELECT con_name, instance_name, state FROM cdb_pdb_saved_states;

SELECT con_id, con_name, state from dba_pdb_saved_states;

Note: When you unplug and plug in the database, this saved state will be lost.

Save the existing State of PDB

-- First close pluggable database
alter pluggable database all close;
OR
-- First open pluggable database
alter pluggable database all open;

-- Save the last state of the database

Discard or unsaved the existing state of PDB

 alter pluggable database PDB1 discard state;
Pluggable database altered.

Show the pdbs

show pdbs

Preserving the Open Mode of All PDBs

ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Preserving the Open Mode of Multiple PDBs

ALTER PLUGGABLE DATABASE PDB1 , PDB2 SAVE STATE;

Preserving the Open Mode of All PDBs Except

ALTER PLUGGABLE DATABASE ALL EXCEPT PDB3, PDB4 SAVE STATE;

Note:
In Case Of RAC CDB, use the instances clause in the pdb_save_or_discard_state clause for specify the instances on which a PDB’s open mode is retained.