SAVE THE CURRENT STATE PERMANENT FOR PDBS DURING NEXT STARTUP IN ORACLE

SAVE THE CURRENT STATE PERMANENT FOR PDBS DURING NEXT STARTUP IN ORACLE

In oracle multitenant, every time the database is restarted, the state of pdbs remain in a default state. Hence to save a particular state for all pdbs, the below commands can be used.

kIsH@Xhydra<>select con_name,state from cdb_pdb_saved_states;

no rows selected

kIsH@Xhydra<>show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDBZX1                         READ WRITE NO
         4 PDBZX2                         READ WRITE NO

kIsH@Xhydra<>alter pluggable database all save state;

Pluggable database altered.

kIsH@Xhydra<>select con_name,state from cdb_pdb_saved_states;

CON_NAME             STATE
-------------------- --------------
PDBZX1               OPEN
PDBZX2               OPEN

Below commands can be used to save state for specific pdb. Here in PDB world, mounted means closed.

kIsH@Xhydra<>alter pluggable database pdbzx1 close immediate;

Pluggable database altered.

kIsH@Xhydra<>alter pluggable database pdbzx1 save state;

Pluggable database altered.

kIsH@Xhydra<>shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
kIsH@Xhydra<>startup;
ORACLE instance started.

Total System Global Area 1962932432 bytes
Fixed Size                  9136336 bytes
Variable Size            1124073472 bytes
Database Buffers          822083584 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
kIsH@Xhydra<>show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDBZX1                         MOUNTED  <<<<<===========
         4 PDBZX2                         READ WRITE NO

To discard the saved state for a PDB, use the below commands

kIsH@Xhydra<>alter pluggable database pdbzx1 discard state;

Pluggable database altered.

kIsH@Xhydra<>select con_name,state from cdb_pdb_saved_states;

CON_NAME             STATE
-------------------- --------------
PDBZX2               OPEN

To discard states for all PDB

kIsH@Xhydra<>alter pluggable database all discard state;

Pluggable database altered.

kIsH@Xhydra<>select con_name,state from cdb_pdb_saved_states;

no rows selected

Leave a Reply

%d bloggers like this: