Starting and shutting down a CDB is the same as a non-CDB. However. starting and shutting down a PDB requires the use of the ALTER PLUGGABLE DATABASE command.
"40.4.6.4 Modifying the Open Mode of PDBs with ALTER PLUGGABLE DATABASE" lists the following examples:
ALTER PLUGGABLE DATABASE salespdb, hrpdb OPEN READ WRITE; ALTER PLUGGABLE DATABASE salespdb OPEN READ ONLY RESTRICTED; ALTER PLUGGABLE DATABASE salespdb OPEN UPGRADE; ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE; ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE FORCE; ALTER PLUGGABLE DATABASE ALL EXCEPT salespdb, hrpdb CLOSE IMMEDIATE;
"40.4.6.5 Modifying the Open Mode of PDBs with the SQL*Plus STARTUP Command" lists the following examples:
STARTUP PLUGGABLE DATABASE hrpdb OPEN STARTUP PLUGGABLE DATABASE hrpdb RESTRICT STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY RESTRICT STARTUP PLUGGABLE DATABASE hrpdb OPEN READ ONLY STARTUP PLUGGABLE DATABASE hrpdb FORCE
All of these commands are run against the JAR CDB on PADSTOW.
Run the following SQL query to get the initial state of all PDBs:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- CDB$ROOT READ WRITE NO JAM READ WRITE NO JAM0 READ WRITE NO JAM1 READ WRITE NO PDB$SEED READ ONLY NO PLUM READ WRITE NO VEGEMITE READ ONLY NO VEGEMITER READ WRITE NO 8 rows selected.
Run the following SQL command to connect to the PLUM PDB:
alter session set container=plum;
The expected output is:
Session altered.
Run the following SQL command:
shutdown immediate
The expected output is:
Pluggable Database closed.
Run the following SQL query to get the current state of PLUM PDB:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- PLUM MOUNTED
Run the following SQL command to start up the PLUM PDB in read/write mode:
startup open
The expected output is:
Pluggable Database opened.
Run the following SQL query to get the current state of PLUM PDB:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- PLUM READ WRITE NO
Run the following SQL command to close the PLUM PDB:
alter pluggable database plum close;
The expected output is:
Pluggable database altered.
Run the following SQL query to get the current state of PLUM PDB:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- PLUM MOUNTED
Run the following SQL command to open the PLUM PDB:
alter pluggable database plum open;
The expected output is:
Pluggable database altered.
Run the following SQL query to get the current state of PLUM PDB:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- PLUM READ WRITE NO
Run the following SQL command to shut down the PLUM PDB while connected to it:
shutdown immediate
The expected output is:
Pluggable Database closed.
Run the following SQL command to connect to the ROOT container:
alter session set container=cdb$root;
The expected output is:
Session altered.
Run the following SQL command to start up the PLUM PDB:
startup pluggable database plum
The expected output is:
Pluggable Database opened.
Run the following SQL query to get the current state of all PDBs:
SELECT name, open_mode, restricted FROM V$CONTAINERS ORDER BY name;
The expected output is:
NAME OPEN_MODE RES ------------------------------ ---------- --- CDB$ROOT READ WRITE NO JAM READ WRITE NO JAM0 READ WRITE NO JAM1 READ WRITE NO PDB$SEED READ ONLY NO PLUM READ WRITE NO VEGEMITE READ ONLY NO VEGEMITER READ WRITE NO 8 rows selected.