How to open pluggable database (PDBs) in Oracle 19 C

How to open pluggable database (PDBs) in Oracle 19 C?

 First need to log in and check the PDB status

C:\WINDOWS\system32>sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 25 21:53:59 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
SQL> conn sys/orcl as sysdba
Connected.
SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONTOOR                         READ WRITE NO
         4 APEX_5                         MOUNTED
         5 APEX_19_2                      READ WRITE NO
         6 APEX_18_2                      READ WRITE NO
SQL>


 So the open mode is mounted for PDB APEX_5. Lets open the PDB.

SQL> alter pluggable database APEX_5 open;
Pluggable database altered.
SQL> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ONTOOR                         READ WRITE NO
         4 APEX_5                         READ WRITE NO
         5 APEX_19_2                      READ WRITE NO
         6 APEX_18_2                      READ WRITE NO
SQL>

  • After altering the Pluggable database OPEN and mode is turned to READ and WRITE.
  • To open all the available PDBs automatically we can create database STARTUP trigger.
CREATE OR REPLACE TRIGGER open_all_pdbs
   AFTER STARTUP
   ON DATABASE
BEGIN
   EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;

How to Close PDBs?

ALTER PLUGGABLE DATABASE apex_5 CLOSE;

And to select the PDB

ALTER SESSION SET CONTAINER = apex_5;