Oracle 12c - Multi Tenancy Architecture

Written by rajkiran on Sunday June 8, 2014

The most exciting feature in 12c is the multi tenancy architecture which will greatly benefit in the database consolidation with reduction in the overhead of resources needed for maintaining multiple instances and easing up lot of DBA administration activities
For backward compatibility, 12c still supports the traditional architecture. You have to explicitly choose the new architecture option when creating new database.

- Traditional pre-12c architecture 
  One-to-One relationship between an instance and a database
- New multi tenancy 12c architecture
  This is a multi container database (CDB)  which contains many pluggable databases stored as separate containers sharing the same container database instance.
To create a CDB, compatible parameter should be set to a minimum of 12.0.0. A CDB and all of its associated PDBs should be of the same database version. 

How to check if the database is created with new architecture?

Query the cdb column in v$database.
SQL> select cdb from v$database;

CDB and the containers

A maximum of 255 Containers is allowed for any CDB.
SQL> select con_id,name,open_mode from v$database
  2  union
  3  select con_id,name,open_mode from v$containers;

    CON_ID NAME                       OPEN_MODE
---------- -------------------------------------------------- --------------------
     0 ORA12                      READ WRITE
     1 CDB$ROOT                      READ WRITE
     2 PDB$SEED                      READ ONLY
     3 PDBORA12                      MOUNTED

Container 0 :  <-- CDB itself 
Container 1 :   ROOT Container ( CDB$ROOT) → Contains objects and meta data related to all the containers.
Container 2  :  SEED Container (PDB$SEED) → Read Only Template used for creating new pluggable databases
Containers 3-254 : User Defined Pluggable database containers  → Names are case insensitive and First character needs to be alphanumeric

Database Files Layout 

SQL> l
  1  select con_id,name,'CONTROLFILE' from v$controlfile
  2  union
  3  select con_id,file_name,tablespace_name from cdb_data_files
  4  union
  5  select con_id,member,'REDOLOG' from v$logfile
  6  union
  7  select con_id,file_name,tablespace_name from cdb_temp_files
  8* order by 1,3

   CON_ID NAME                                                 'CONTROLFILE'
---------- ---------------------------------------------------------------------------------------------------- ------------------------------
     0 /data/oracle/app/oracle/oradata/ora12/control01.ctl                            CONTROLFILE
     0 /data/oracle/app/oracle/recovery_area/ora12/control02.ctl                        CONTROLFILE
     0 /data/oracle/app/oracle/oradata/ora12/redo01.log                            REDOLOG
     0 /data/oracle/app/oracle/oradata/ora12/redo02.log                            REDOLOG
     0 /data/oracle/app/oracle/oradata/ora12/redo03.log                            REDOLOG
     1 /data/oracle/app/oracle/oradata/ora12/sysaux01.dbf                            SYSAUX
     1 /data/oracle/app/oracle/oradata/ora12/system01.dbf                            SYSTEM
     1 /data/oracle/app/oracle/oradata/ora12/temp01.dbf                            TEMP
     1 /data/oracle/app/oracle/oradata/ora12/undotbs01.dbf                            UNDOTBS1
     1 /data/oracle/app/oracle/oradata/ora12/users01.dbf                            USERS
     2 /data/oracle/app/oracle/oradata/ora12/pdbseed/sysaux01.dbf                        SYSAUX
     2 /data/oracle/app/oracle/oradata/ora12/pdbseed/system01.dbf                        SYSTEM
     2 /data/oracle/app/oracle/oradata/ora12/pdbseed/pdbseed_temp01.dbf                    TEMP

Some Notes :  

Control Files and Redo Logs are specified at the instance level (Container 0) only.
UNDO and default TEMP tablespaces are defined at the Root Container level and are shared with all the PDBS
SYSTEM and SYSAUX in the root container contain all the data dictionary for all the PDBS. It also contains pointers to the data dictionary information for the individual PDBS. 
There is only one parameter file specified for the entire CDB. However, a PDB can have its own specific set of parameters. This information is stored in the PDB’s local data dictionary under SYSAUX and SYTEM tablespaces
No user defined tablespaces can exist at the container level. 
PDBs along with the user defined tablespaces, can also have their own set of temp tablespaces.