LESSON 12
How to manage a Multitenant Container Database (CDB) and Pluggable
Databases (PDBs)
How to startup and shutdown a Multitenant Container Database (CDB)
# cd ~
# . ./.profile
# sqlplus /nolog
SQL> connect /
as sysdba
--Just
to make sure where you are
Get the container name
SQL> show
con_name
List or query the
V$DATABASE view.
SQL> SELECT
name, cdb, con_id FROM v$database;
NAME |
CDB |
CON_ID |
MYCDB |
YES |
0 |
Note: The CDB column
value is "YES."
Shutdown the Multitenant
Container database (CDB)
SQL> SHUTDOWN
IMMEDIATE;
You can use all the
shutdown and startup option as we covered them at the previous lessons
on the non-CDB database such as:
SQL> STARTUP
NOMOUNT;
SQL> ALTER
DATABASE MOUNT;
To startup:
SQL> STARTUP;
List or query the
V$DATABASE view.
SQL> SELECT
name, cdb, con_id FROM v$database;
NAME |
CDB |
CON_ID |
MYCDB |
YES |
0 |
How to open and close Pluggable Databases (PDBs)
Since you shutdown the
multitenant container, all the PDBs were closed. When you startup the
CDB, all the PDBs are going to be on the MOUNTED mode.
Get the list of all PDBs
to check the PDBs open mode.
SQL> SELECT
con_id, name, open_mode, dbid FROM v$pdbs;
CON_ID |
NAME |
OPEN_MODE |
DBID |
2 |
PDB$SEED |
READ ONLY |
3654327692 |
3 |
MYPDB1 |
MOUNTED |
6783241652 |
4 |
MYPDB2 |
MOUNTED |
7549320153 |
5 |
MYPDB2_CLONE |
MOUNTED |
8734290212 |
6 |
PDB_MYDBS |
MOUNTED |
2378654330 |
Notice that all PDBs are
at the MOUNTED mode. You need to open
them in order to change the mode to READ WRITE
Open one or all.
To open one:
SQL> ALTER
PLUGGABLE DATABAE
mypdb1
OPEN;
Get the list of all PDBs
to check the PDBs open mode.
SQL> SELECT
con_id, name, open_mode, dbid FROM v$pdbs;
CON_ID |
NAME |
OPEN_MODE |
DBID |
2 |
PDB$SEED |
READ ONLY |
3654327692 |
3 |
MYPDB1 |
READ WRITE |
6783241652 |
4 |
MYPDB2 |
MOUNTED |
7549320153 |
5 |
MYPDB2_CLONE |
MOUNTED |
8734290212 |
6 |
PDB_MYDBS |
MOUNTED |
2378654330 |
Notice that the
mypdb1 was changed the
READ WRITE mode.
To open all PDBs
SQL> ALTER
PLUGGABLE DATABAE
all
OPEN;
Pluggable database
altered.
Get the list of all PDBs
to check the PDBs open mode.
SQL> SELECT
con_id, name, open_mode, dbid FROM v$pdbs;
CON_ID |
NAME |
OPEN_MODE |
DBID |
2 |
PDB$SEED |
READ ONLY |
3654327692 |
3 |
MYPDB1 |
READ WRITE |
6783241652 |
4 |
MYPDB2 |
READ WRITE |
7549320153 |
5 |
MYPDB2_CLONE |
READ WRITE |
8734290212 |
6 |
PDB_MYDBS |
READ WRITE |
2378654330 |
Notice that the PDBs
open mode were changed.
To close the mypdb1
pluggable database
SQL> ALTER
PLUGGABLE DATABAE
mypdb1
CLOSE IMMEDIATE;
Pluggable database
altered.
Get the list of all PDBs
open mode.
SQL> SELECT
con_id, name, open_mode, dbid FROM v$pdbs;
CON_ID |
NAME |
OPEN_MODE |
DBID |
2 |
PDB$SEED |
READ ONLY |
3654327692 |
3 |
MYPDB1 |
MOUNTED |
6783241652 |
4 |
MYPDB2 |
READ WRITE |
7549320153 |
5 |
MYPDB2_CLONE |
READ WRITE |
8734290212 |
6 |
PDB_MYDBS |
READ WRITE |
2378654330 |
Notice that the mypdb1
open mode was changed to "MOUNTED."
Start it again.
SQL> ALTER
PLUGGABLE DATABAE
mypdb1
OPEN;
Use the created service
name to connect to them but not PDB$SEED which it is READ ONLY mode.
Connect to mypdb1.
SQL> connect
sys/mypass@mypdb1 as sysdba
List the V$PDBS view.
SQL> SELECT
con_id, name, open_mode FROM v$pdbs;
NAME |
OPEN_MODE |
CON_ID |
MYPDB1 |
READ WRITE |
3 |
Notice that the seed PDB
(PDB$SEED) is not here. That means
the PDB does not see it.
Using SHOW CON_NAME and
CON_ID
Getting the PDB name:
SQL> show
con_name
If you wish to open all
PDBs except mypdb1, you can perform the following command.
SQL> ALTER
PLUGGABLE DATABASE
all
EXCEPT
mypdb1 OPEN;
Good Luck!
|