How to set Oracle Pluggable Database Automatic startup with Container

In Oracle Database 12c and above, the Multitenant Architecture was introduced, allowing for the creation of multiple Pluggable Databases (PDBs) within a single Container Database (CDB). To ensure seamless operation and availability of the PDBs, it is essential to configure automatic startup for the PDBs during database startup. This blog article will guide you through the steps to set up automatic startup for Oracle Pluggable Databases.


Steps:

1) Connect to the CDB


Start by connecting to the Container Database (CDB) using SQL*Plus

$sqlplus / as sysdba

SQL>show con_name
CON_NAME
------------
CDB$ROOT

2) Check Current Startup Mode


Execute the following query to check the current startup mode of the PDBs:


SELECT name, open_mode FROM v$pdbs;

Or

SQL>show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 FPDB1                           MOUNTED
         4 FPDB2                           MOUNTED

The open mode should be set to "MOUNTED" for the PDBs that you want to configure for automatic startup.

3) Open the PDBS using below command


SQL> alter pluggable database fpdb1 open read write;

Pluggable database altered.

SQL> alter pluggable database fpdb2 open read write;

Pluggable database altered.

SQL> show pdbs

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

4) Configure PDB for Automatic Startup


SQL> alter pluggable database fpdb1 save state;

Pluggable database altered.

SQL> alter pluggable database fpdb2 save state;

Pluggable database altered.



5) Check the pdbs saved state using dba_pdb_saved_states views


SQL> select con_name,state from dba_pdb_saved_states

CON_NAME             STATE
-------------------- --------------
FPDB1                 OPEN
FPDB2                 OPEN

6) Bounce the cdb and check the pdbs state


SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


SQL> startup
ORACLE instance started.
Database mounted.
Database opened.

SQL> show pdbs

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


If we want to Discard the pdbs saved state


SQL> alter pluggable database fpdb1 discard state;

Pluggable database altered.


SQL> select con_name,state from dba_pdb_saved_states;

CON_NAME             STATE
-------------------- --------------
FPDB2                 OPEN

Now we can see saved state for only one pdf

Restart the CDB and check pdbs status

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 FPDB1                           MOUNTED
         4 FPDB2                           READ WRITE NO





If you like please follow and comment