Overview
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.
References
- Database Administrator’s Guide
- 3 Starting Up and Shutting Down
- 40 Administering a CDB with SQL*Plus
- 42 Administering PDBs with SQL*Plus
- Oracle® 12.1 Database Reference
- Oracle® 12.1 SQL Language Reference
- SQL*Plus® User's Guide and Reference 12.1
Reading Notes
" 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
Procedure
All of these commands are run against the JAR CDB on PADSTOW .
Get Initial State of All PDBs
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.
Connect to PLUM PDB
Run the following SQL command to connect to the PLUM PDB:
alter session set container=plum;
The expected output is:
Session altered.
Shut Down PLUM PDB
Run the following SQL command:
shutdown immediate
The expected output is:
Pluggable Database closed.
Get Current State of PLUM PDB
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
Start Up PLUM PDB While Connected to PLUM
Run the following SQL command to start up the PLUM PDB in read/write mode:
startup open
The expected output is:
Pluggable Database opened.
Get Current State of PLUM PDB
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
Close PLUM PDB
Run the following SQL command to close the PLUM PDB:
alter pluggable database plum close;
The expected output is:
Pluggable database altered.
Get Current State of PLUM PDB
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
Open PLUM PDB
Run the following SQL command to open the PLUM PDB:
alter pluggable database plum open;
The expected output is:
Pluggable database altered.
Get Current State of PLUM PDB
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
Shut Down PLUM PDB While Connected to PLUM
Run the following SQL command to shut down the PLUM PDB while connected to it:
shutdown immediate
The expected output is:
Pluggable Database closed.
Connect to Root Container
Run the following SQL command to connect to the ROOT container:
alter session set container=cdb$root;
The expected output is:
Session altered.
Start Up PLUM PDB While Connected to ROOT Container
Run the following SQL command to start up the PLUM PDB:
startup pluggable database plum
The expected output is:
Pluggable Database opened.
Get Current State of All PDBs
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.