Oracle Multitenant

Overview
Database 12c Enterprise Edition introduces Multitenant, a new design that empowers clients to effortlessly merge numerous databases, without changing their applications.
This new design gives the advantages of overseeing various databases as one, yet holds the confinement and asset prioritization of discrete databases. Multitenant empowers fast provisioning and completely supplements with other functionalities like Oracle Real Application Clusters and Active Data Guard.

What is Multitenant
The new design is termed as multitenant as multiple tenants shares the same resources on a mutual benefit. The same is applied to the Oracle Database where the multitenant foundation called as Container Database (CDB)  has various tenants known as Pluggable database(PDB).

Advantages of Multitenant
In the earlier releases of database we were not been able to utilize the full hardware or other resources on the server/virtual machine where the database is running. Oracle wanted to overcome this and to makes sure we are using the hardware to their full capacity, so they came up with this feature. It will also help in cost reduction. Multitenancy helps is easier upgrades and patching activities. Numerous databases clubbed as one which even give performance tuning benefits as we have single sga/memory structure to tune.

Architecture Overview
In Oracle multitenancy architecture the container database is a single instance which comprises of background and memory structures same like non–container databases, but the memory would also be shared with all pluggable databases as well which distinguishes the multitenant design with the earlier conventional databases. It is like earlier Oracle databases, as it contains the majority of the working parts like (controlfiles, datafiles, undo, tempfiles, archivefiles,redofiles etc.)



Architecture Diagram

The architecture basically consists of the following containers:

Root  Container
·         It is the core of the CDB, contains all Oracle supplied metadata like packages, core dictionary objects, and common users. It can be identified as CDB$ROOT. There is only one root container for a CDB.
·         Control files, REDO Logs, and UNDO files are owned by ROOT Container as these Database files are Instance specific

Seed PDB
·         It is a template database which can is used to create new PDBs, Oracle copies mandatory datafiles (common datafiles) for creation of PDB from this SEED Database.
·         This is by default in READ-ONLY mode and cannot be altered or modified.
·         This is identified as PDB$SEED.

User Defined PDB
·         It is the custom PDBs which may be created for various applications, teams or functionalities.
·         There can be zero or more PDB’s in a CDB.
·         One PDB can be associated with only CDB at a time.
·         A CDB can contain 253 PDBs including the SEED Container.
·         Every PDB has its own set of SYSTEM/SYSAUX/TEMP tablespaces. If we don’t assign any TEMP tabalespace to PDB it will use the TEMP of ROOT Container.
·         When a Container database instance is started all PDB’s comes automatically in mounted state. We will need to manually open the PDB’s into Read-Write mode.
For all above containers we have container id defined.
Container ID
Container Name
0
Whole CDB, or non-CDB
1
CDB$ROOT
2
PDB$SEED
3 and above
All Custom PDB’s

In the earlier version of Databases we have 3 level of dictionary view relationship (USER_,ALL_,DBA_) but with the introduction of the CDB one more layer of view has increased (CDB_).


Let’s go through some Basic Commands.




Connect to CDB
sqlplus “/as sysdba”
SQL> sho con_name
CON_NAME
------------------------------
CDB$ROOT
Connect to PDB Using Alter Session Command
Connect to CDB as described above then connect to PDB using following command.
alter session set container=pdb2;
Session altered.
Find Database is CDB or Non-CDB
SQL> SELECT NAME, CDB, CON_ID FROM V$DATABASE;
NAME   CDB   CON_ID
--------- --- ----------
CDB1   YES        0
Checking the Status of PDBs
SQL> SELECT NAME,OPEN_MODE FROM V$PDBS;



NAME                           OPEN_MODE  
------------------------------ ---------- 
PDB$SEED                       READ ONLY
PDB                            READ WRITE   

SALESPDB                       MOUNTED