This article will be discussing a new feature of Oracle 12c Database, Oracle Multitenant Architecture, which enables an Oracle Database to act as multitenant Container Database (CDB). A CDB includes one or many pluggable databases (PDBs). One default PDB, the seed PDB, is provided by Oracle in every CDB. Users cannot make changes to the seed PDB, but user can create additional PDBs using this default PDB. A CDB can contain 253 PDBs.

Structure of CDB

 

  1. Containers
    A CDB has two components, a root container and PDBs contained inside the container. The root container is a collection of system and non-schema objects to which all PDBs belongs. Every CDB has following containers:

     

    • Only one root container Every CDB has exactly one root container known as CDB$ROOT. All PDBs belongs to this root container. It consists of system and non-schema objects to which all PDBs belong. System objects include database level objects, such as redo logs, control files, etc. Non-schema objects means metadata to manage all PDBs. You should not add user data to root container, but you can add new users and roles with appropriate privileges for administration purposes, this will add metadata to root container.
    • Only one seed PDB Every CDB has exactly one seed PDB known as PDB$SEED, which is Oracle-supplied PDB and can be used as template to create new PDBs. You cannot alter PDB$SEED. It only works in READ ONLY mode.
    • Zero or more user-created PDBs You can create PDBs from PDB$SEED and create objects and code as per your business requirements. You can also create PDBs by cloning existing PDB.
  2. Common User
    Root container has some common users which are known to every container like SYS and SYSTEM. Every PDB container has its own objects and is managed by PDB administrator, which is local to only particular PDB.

In other words you can think of a CDB as a conventional Oracle database, in terms of having controlfiles, datafiles, undo tablespaces, tempfiles, redo logs etc. It also contains the data dictionary for objects owned by root container and objects which are visible to all PDBs. Conversely, the PDBs only contain data and data dictionary metadata to itself and have nothing to worry about instance files, described above. They are similar to schemas, but are completely independent of other PDBs.

You can easily plug/associate a PDB into a CDB and unplug/disaccociate a PDB from a CDB. An unplugged PDB consists of an XML file that describes the PDB and the PDB’s files. You can unplug a PDB from one CDB and plug it into a different CDB without altering your schemas or applications. A PDB can be plugged into only one CDB at a time.

Benefits

  • Easier migration of data and code With Oracle Multitenant Architecture, instead of upgrading a CDB to a higher release, you can unplug a PDB and plug into a CDB which is from a higher release.
  • Easier deployment to production You can develop a PDB on test CDB and once ready for production, unplug it from test CDB and plug it into a production CDB.

Data Dictionary Views

Oracle 12c database also introduces a layer on top of data dictionary views in pre-12c databases. CDB_* views contain information of all objects in root container and all PDBs. Rest of DBA_*, ALL_* and USER_* views are same as in pre-12c databases.

Creation of CDB

Run Database Creation Assistant (DBCA):

Click Next

Click Next

Click Finish

After the DBCA creation is complete, let’s verify our new container database.

SQL> SELECT NAME, CDB FROM V$DATABASE;

NAME  CDB
----- ---
MYCDB YES

SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') CONTAINER FROM DUAL;

CONTAINER
---------
CDB$ROOT

1 Comment