Pluggable Database Saved State in Oracle
Saved State is a feature in 12.1.0.2 that remembers the OPEN state of all PDBs when the CDB restarts. It ensures PDBs return to the same state: if a PDB was open, it will be opened again, and if it was closed, it will remain closed after the restart. The database saves its state in READ-WRITE or READ-ONLY mode.
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.