User Tools

Site Tools


multitenantarchitecture

This is an old revision of the document!


Multitenant Architecture

Opening / Closing Pluggable Databases

SQL> alter session set container = pdb2;

Session altered.

SQL> shutdown 
Pluggable Database closed.
SQL> startup
Pluggable Database opened.
SQL> alter pluggable database pdb2 close;

Pluggable database altered.

SQL> alter pluggable database pdb2 open;

Pluggable database altered.

I think it always safer to use the “alter pluggable” command so you definitely know which database you are closing.

Sometimes you may get an error when opening a pluggable database

SQL> alter pluggable database pdb2 open;

Warning: PDB altered with errors.

The “show pdbs” reveals that pluggable database pdb2 has been opened in restricted mode.

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB1 			  READ WRITE NO
	 4 PDB2 			  READ WRITE YES

Use the view PDB_PLUG_IN_VIOLATIONS to see what the error is.
The full error message is not always written to the Alert Log.

select time, message from pdb_plug_in_violations;

TIME                      MESSAGE
------------------------- --------------------------------------------------------------------------------
28-JUL-15 08.59.31.507182 Sync PDB failed with ORA-959 during 'CREATE USER c##ian IDENTIFIED BY *DEFAULT T
                          ABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP" container = all'

In the above case I had forgotten to create the tablespace users in database pdb2.

Unplugging a PDB

SQL> alter session set container=pdb2;

Session altered.

SQL> shutdown immediate;
Pluggable Database closed.
SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 4 PDB2 			  MOUNTED

SQL> conn / as sysdba
Connected.
SQL> alter pluggable database pdb2 unplug into '/home/oracle/pdb2.xml';

Pluggable database altered.

SQL> select pdb_name, status from dba_pdbs;

PDB_NAME	STATUS
--------------- ---------
PDB$SEED	NORMAL
PDB1		NORMAL
PDB2		UNPLUGGED

SQL> drop pluggable database pdb2;

Pluggable database dropped.

Plugging In an Unplugged PDB

For this example I will simply plug back in the database that was dropped from above.
If I was moving the PDB to a new location on the server I would need to use the 'copy' parameter at the end of the command.

SQL> create pluggable database pdb3 using '/home/oracle/pdb2.xml';

Pluggable database created.
multitenantarchitecture.1438080362.txt.gz · Last modified: 2025/03/08 22:23 (external edit)