The multitenant architecture enables an Oracle database to function as a multitenant container database (CDB).
A CDB includes zero, one, or many customer-created pluggable databases (PDBs). A PDB is a portable collection of schemas, schema objects, and nonschema objects that appears to an Oracle Net client as a non-CDB. All Oracle databases before Oracle Database 12c were non-CDBs.
Containers in a CDB
A container is logical collection of data or metadata within the multitenant architecture.
Every CDB has the following containers:
- Exactly one CDB root container (also called simply the root)
The CDB root is a collection of schemas, schema objects, and nonschema objects to which all PDBs belong. The root stores Oracle-supplied metadata and common users. An example of metadata is the source code for Oracle-supplied PL/SQL packages. A common user is a database user known in every container. The root container is named
- Exactly one system container
The system container includes the root CDB and all PDBs in the CDB. Thus, the system container is the logical container for the CDB itself.
- Zero or more application containers
An application container consists of exactly one application root, and the PDBs plugged in to this root. Whereas the system container contains the CDB root and all the PDBs within the CDB, an application container includes only the PDBs plugged into the application root. An application root belongs to the CDB root and no other container.
- Zero or more user-created PDBs
A PDB contains the data and code required for a specific set of features (see “PDBs”). For example, a PDB can support a specific application, such as a human resources or sales application. No PDBs exist at creation of the CDB. You add PDBs based on your business requirements.
A PDB belongs to exactly zero or one application container. If a PDB belongs to an application container, then it is an application PDB. For example, the
cust2_pdb application PDBs might belong to the
saas_sales_ac application container, in which case they belong to no other application containers. An application seed is an optional application PDB that acts as a user-created PDB template, enabling you to create new application PDBs rapidly.
- Exactly one seed PDB
The seed PDB is a system-supplied template that the CDB can use to create new PDBs. The seed PDB is named
PDB$SEED. You cannot add or modify objects in
User Interfaces for the Multitenant Architecture
You can use the same administration tools for both CDBs and non-CDBs.
Tools in a Multitenant Environment
|SQL*Plus and SQL Developer for command-line access||SQL*Plus is an interactive and batch query tool that is installed with Oracle Database.|
|Oracle Enterprise Manager Cloud Control (Cloud Control)||Cloud Control is an Oracle Database administration tool that provides a graphical user interface (GUI). Cloud Control supports Oracle Database 12c targets, including PDBs, CDBs, and non-CDBs.|
|Oracle Enterprise Manager Database Express (EM Express)||EM Express is a web-based management product built into the Oracle database. EM Express enables you to provision and manage PDBs, including the following operations: Creating and dropping PDBsPlugging in and unplugging and PDBsCloning PDBsSetting resource limits for PDBs|
|Oracle Database Configuration Assistant (DBCA)||DBCA is a utility with a graphical user interface that enables you to create and duplicate CDBs. It also enables you to create, relocate, clone, plug in, and unplug PDBs.|
Challenges for a Non-CDB Architecture
Large enterprises may use hundreds or thousands of databases. Often these databases run on different platforms on multiple physical servers.
Because of improvements in hardware technology, especially the increase in the number of CPUs, servers can handle heavier workloads than before. A database may use only a fraction of the server hardware capacity. This approach wastes both hardware and human resources.
Typical responses include:
- Use virtual machines (VMs).
In this model, you replicate the operating infrastructure of the physical server—operating system and database—in a virtual machine. VMs are agile, but use technical resources inefficiently, and require individual management. Virtual sprawl, which is just as expensive to manage, replaces the existing physical sprawl.
- Place multiple databases on each server.
Separate databases eliminate operating system replication, but do not share background processes, system and process memory, or Oracle metadata. The databases require individual management.
- Separate the data logically into schemas or virtual private databases (VPDs).
This technique uses technical resources efficiently. You can manage multiple schemas or VPDs as one. However, this model is less agile than its alternatives, requiring more effort to manage, secure, and transport. Also, the logical model typically requires extensive application changes, which discourages adoption.
Multitenant Architecture for Database Consolidation
Database consolidation is the process of consolidating data from multiple databases into one database on one computer. The Oracle Multitenant option enables you to consolidate data and code without altering existing schemas or applications.
The PDB/non-CDB compatibility guarantee means that a PDB behaves the same as a non-CDB as seen from a client connecting with Oracle Net. The installation scheme for an application definition (for example, tables and PL/SQL packages) that runs against a non-CDB runs the same against a PDB and produces the same result. Also, the run-time behavior of client code that connects to the PDB containing the application definition is identical to the behavior of client code that connected to the non-CDB containing this application definition.
Operations that act on an entire non-CDB act in the same way on an entire CDB, for example, when using Oracle Data Guard and database backup and recovery. Thus, the users, administrators, and developers of a non-CDB have substantially the same experience after the database has been consolidated.
Starting in Oracle Database 12c Release 2 (12.2), you can create an application container that contains application PDBs. This approach enables you to create and manage an application within this container. Most benefits that apply to consolidation into a CDB also apply to consolidation within an application container.
Using the multitenant architecture for database consolidation has the following benefits:
- Cost reduction
By consolidating hardware and database infrastructure to a single set of background processes, and efficiently sharing computational and memory resources, you reduce costs for hardware and maintenance. For example, 100 PDBs on a single server share one database instance.
- Easier and more rapid movement of data and code
By design, you can quickly plug a PDB into a CDB, unplug the PDB from the CDB, and then plug this PDB into a different CDB. You can also clone PDBs while they remain available. You can plug in a PDB with any character set and access it without character set conversion. If the character set of the CDB is AL32UTF8, then PDBs with different database character sets can exist in the same CDB.
- Easier management and monitoring of the physical database
The CDB administrator can manage the environment as an aggregate by executing a single operation, such as patching or performing an RMAN backup, for all hosted tenants and the CDB root. Backup strategies and disaster recovery are simplified.
- Separation of data and code
Although consolidated into a single physical database, PDBs mimic the behavior of non-CDBs. For example, if user error loses critical data, then a PDB administrator can use Oracle Flashback or point-in-time recovery to retrieve the lost data without affecting other PDBs.
- Secure separation of administrative duties
A common user can connect to any container on which it has sufficient privileges, whereas a local user is restricted to a specific PDB. Administrators can divide duties as follows:
- An administrator uses a common account to manage a CDB or application container. Because a privilege is contained within the container in which it is granted, a local user on one PDB does not have privileges on other PDBs within the same CDB.
- An administrator uses a local account to manage an individual PDB.
- Ease of performance tuning
It is easier to collect performance metrics for a single database than for multiple databases. It is easier to size one SGA than 100 SGAs.
- Fewer database patches and upgrades
It is easier to apply a patch to one database than to 100 databases, and to upgrade one database than to upgrade 100 databases.
Multitenant Architecture for Manageability
The multitenant architecture has benefits beyond database consolidation. These benefits derive from storing the data and metadata specific to a PDB in the PDB itself rather than storing all dictionary metadata in one place.
By storing its own dictionary metadata, a PDB becomes easier to manage as a distinct unit. This benefit occurs even when only one PDB resides in a CDB. Grouping PDBs into a separately managed application container increases manageability even further.
In a CDB, the data dictionary metadata is split between the root and the PDBs. Benefits of data dictionary separation include the following:
- Easier upgrade of data and code
For example, instead of upgrading a CDB from one database release to another, you can rapidly unplug a PDB from the existing CDB, and then plug it into a newly created CDB from a higher release.
- Easier migration between servers
To perform load balancing or to meet SLAs, you can migrate an application database from an on-premise data center to the cloud, or between two servers in the same environment.
- Protection against data corruption within a PDB
You can flash back a PDB to an SCN or PDB-specific restore point, without affecting other PDBs. This feature is analogous to the Flashback Database feature for a non-CDB.
- Ability to install, administer, and upgrade application-specific data and metadata in a single place
You can define a set of application-specific PDBs as a single component, called an application container. You can then define one or more applications within this container. Each application is a named, versioned set of common metadata and data shared within this application container.
For example, each customer of a SaaS vendor could have its own application PDB. Each application PDB might have identically defined tables named
sales_mlt, with different data in each PDB. The PDBs could share a data-linked common object named
countries_olt, which has identical data in each PDB. As an application administrator, you could manage the master application definition so that every new customer gets a PDB with the same objects, and every change to existing schemas (for example, the addition of a new table, or a change in the definition of a table) applies to all PDBs that share the application definition.
- Integration with Oracle Database Resource Manager
In a multitenant environment, one concern is contention for system resources among the PDBs running on the same server. Another concern is limiting resource usage for more consistent, predictable performance. To address such resource contention, usage, and monitoring issues, use Oracle Database Resource Manager.
Steps to Database Consolidation
For the duration of its existence, a database is either a CDB or a non-CDB.
You must define a database as a CDB at creation, and then create PDBs and application containers within this CDB. You cannot later transform a non-CDB into a CDB, or a CDB into a non-CDB.
Creation of a CDB
CREATE DATABASE ... ENABLE PLUGGABLE DATABASE SQL statement creates a new CDB.
If you do not specify the
ENABLE PLUGGABLE DATABASE clause, then the newly created database is a non-CDB. In this case, the non-CDB can never contain PDBs.
When you create a CDB, Oracle Database automatically creates a root container (
CDB$ROOT) and a seed PDB (
PDB$SEED). The following graphic shows a newly created CDB:
Determining Whether a Database Is a CDB
The following simple query determines whether the database to which an administrative user is currently connected is a non-CDB, or a container in a CDB:
SQL> SELECT NAME, CDB, CON_ID FROM V$DATABASE;
NAME CDB CON_ID
--------- --- ----------
CDB1 YES 0
Creation of a PDB
CREATE PLUGGABLE DATABASE SQL statement creates a PDB.
The created PDB automatically includes a full data dictionary including metadata and internal links to system-supplied objects in the CDB root. You must define every PDB from a single root: either the CDB root or an application root.
Each PDB has a globally unique identifier (GUID). The PDB GUID is primarily used to generate names for directories that store the PDB’s files, including both Oracle Managed Files directories and non-Oracle Managed Files directories.
Creation of a PDB by Cloning
One technique for creating a PDB is called cloning.
You can clone a PDB from
PDB$SEED, an application seed, a remote or local PDB, or a non-CDB.
Creation of a PDB from a Seed
You can use the
CREATE PLUGGABLE DATABASE statement to create a PDB from a seed.
A seed is a PDB that serves as a template for creation of another PDB. Creating a PDB from a seed copies some or all of the contents of a PDB, and then assigns a new unique identifier.
A seed PDB is either of the following:
- The PDB seed (
PDB$SEED), which is a system-supplied template for creating PDBs
Every CDB has exactly one
PDB$SEED, which cannot be modified or dropped.
- An application seed, which is a user-created PDB for a specified application root
Within an application container, you can create an application seed using the
CREATE PLUGGABLE DATABASE AS SEED statement, which you can then use to accelerate creation of new application PDBs.
Creation of a PDB from PDB$SEED
The following SQL statement creates a PDB named
PDB$SEED using Oracle Managed Files:
CREATE PLUGGABLE DATABASE hrpdb
ADMIN USER dba1 IDENTIFIED BYpassword
Creation of a PDB by Cloning a PDB or a Non-CDB
To clone a PDB or non-CDB, use the
CREATE PLUGGABLE DATABASE statement with the
In this technique, the source is either a non-CDB, or a PDB in a local or remote CDB. The target is the PDB copied from the source. The cloning operation copies the files associated with the source to a new location, and then assigns a new GUID to create the PDB.
This technique is useful for quickly creating PDBs for testing and development. For example, you might test a new or modified application on a cloned PDB before deploying the application in a production PDB. If a PDB is in local undo mode, then the source PDB can be open in read/write mode during the operation, referred to as hot cloning.
If you run
CREATE PLUGGABLE DATABASE statement in an application root, then the cloned PDB is created in the application container. In this case, the application name and version of the source PDB must be compatible with the application name and version of the application container.
The following graphic illustrates cloning a PDB when both source and target are in the same CDB.
Starting in Oracle Database 19c, you can clone a remote PDB using DBCA.
Cloning a PDB
The following SQL statement clones a PDB named
salespdb from the plugged-in PDB named
CREATE PLUGGABLE DATABASE salespdb FROM hrpdb;
Clones from PDB Snapshots
Create a clone from a PDB snapshot by specifying
USING SNAPSHOT clause of the
CREATE PLUGGABLE DATABASE command.
Creation of PDB Snapshots with the SNAPSHOT Clause
A PDB snapshot is a point-in-time copy of a PDB. The source PDB can be open read-only or read/write while the snapshot is created. A PDB snapshot taken while the source PDB is open is called a hot clone. You can create clones from PDB snapshots. These clone PDBs are useful in development and testing.
You can create snapshots manually using the
SNAPSHOT clause of
CREATE PLUGGABLE DATABASE (or
ALTER PLUGGABLE DATABASE), or automatically using the
EVERY interval clause. The following statement creates a PDB snapshot with the name
ALTER PLUGGABLE DATABASE SNAPSHOT pdb1_wed_4_1201;
If the storage system supports sparse clones, then the preceding command creates a sparse copy. Otherwise, the command creates a full copy.
Every PDB snapshot is associated with a snapshot name and the SCN and timestamp at snapshot creation.
Creation of a PDB Clone with the USING SNAPSHOT Clause
A clone from a PDB snapshot is a full, standalone PDB. Unlike a snapshot copy PDB, which is based on a storage-managed snapshot, you do not need to materialize a clone created from a PDB snapshot.
To create a clone from a PDB snapshot, specify the
USING SNAPSHOT clause of the
CREATE PLUGGABLE DATABASE statement. For example, the following statement clones a PDB named
pdb1_copy from the PDB-level snapshot named
CREATE PLUGGABLE DATABASE pdb1_copy FROM pdb1
USING SNAPSHOT pdb1_wed_4_1201;
Snapshot Copy PDBs
A snapshot copy PDB is based on a copy of the underlying storage system. Snapshot copy PDBs reduce the amount of storage required for testing purposes and reduce creation time significantly.
If the file system supports storage snapshots, then
CREATE PLUGGABLE DATABASE ... FROM ... SNAPSHOT COPY copies a PDB from a source PDB, which can be read/write during the operation. The snapshot copy PDB files use copy-on-write technology. Only modified blocks require extra storage on disk. If the file system does not support storage snapshots or use Oracle Exadata sparse files, then the
CLONEDB initialization parameter must be
true, and the source PDB must be read-only for as long as the snapshot copy PDB exists.
Because a snapshot copy PDB depends on storage-managed snapshots, you cannot unplug a snapshot copy PDB from the CDB root or application root. You cannot drop the storage snapshot on which a snapshot copy PDB is based.
You can transform a snapshot copy PDB, which uses sparse files, into a full PDB. This process is known as materializing the snapshot copy PDB. Because a materialized PDB does not depend on the source PDB, you can drop it. Materialize a PDB by running the
ALTER PLUGGABLE DATABASE MATERIALIZE command.
Refreshable Clone PDBs
A refreshable clone PDB is a read-only clone that can periodically synchronize with its source PDB.
Depending on the value specified in the
REFRESH MODE clause, synchronization occurs automatically or manually. For example, if
hrpdb_re_clone is a clone of
hrpdb, then every month you could manually refresh
hrpdb_re_clone with changes from
hrpdb. Alternatively, you could configure
hrpdb to propagate changes to
hrpdb_re_clone automatically every 24 hours.
You can switch the roles of a source PDB and its refreshable clone. This switchover can be useful for load balancing between CDBs, and when the source PDB suffers a failure.
Creation of a PDB by Plugging In
You can create a PDB by plugging in an unplugged PDB, or plugging in a non-CDB as a PDB.
Creation of a PDB by Plugging In an Unplugged PDB
An unplugged PDB is a self-contained set of data files, and an XML metadata file that specifies the locations of the PDB files. To plug in an unplugged PDB, use the
CREATE PLUGGABLE DATABASE statement with the
When plugging in an unplugged PDB, you have the following options:
- Specify the XML metadata file that describes the PDB and the files associated with the PDB.
- Specify a PDB archive file, which is a compressed file that contains both the XML file and PDB data files. You can create a PDB by specifying the archive file, and thereby avoid copying the XML file and the data files separately.
The following graphic illustrates plugging in an unplugged PDB using the XML file.
Plugging In a PDB
The following SQL statement plugs in a PDB named
salespdb based on the metadata stored in the named XML file, and specifies
NOCOPY because the files of the unplugged PDB do not need to be moved to a new location:
CREATE PLUGGABLE DATABASE salespdb USING '/disk1/usr/salespdb.xml' NOCOPY;
Creation of a PDB from a Non-CDB
You can move a non-CDB into a PDB.
You can accomplish this task in the following ways:
DBMS_PDB.DESCRIBEon a non-CDB in Oracle Database 12c
You place a non-CDB in a transactionally consistent state, and then run the
DBMS_PDB.DESCRIBE function to generate XML metadata about this database. While connected to the root in the CDB, you execute the
CREATE PLUGGABLE DATABASE statement to create a PDB from the existing non-CDB. Finally, to convert the definitions in the PDB data dictionary to references to objects in
CDB$ROOT, log in to the PDB and run the
- Using Oracle Data Pump with or without transportable tablespaces
You can define a data set on a non-CDB using Oracle Data Pump. This non-CDB can be in the current or a previous Oracle Database release, for example, Oracle Database 10g. You create an empty PDB in an existing CDB, and then use Oracle Data Pump to import the data set into the PDB.
A Full Transportable Export using Oracle Data Pump exports all objects and data necessary to create a complete copy of the database. Oracle Data Pump exports objects using direct path unload and external tables, and then imports objects using direct path
INSERT and external tables. The Full Transportable dump file contains all objects in the database, not only table-related objects. Full Transportable Export is available starting in Oracle Database 11g Release 2 (22.214.171.124) for import into Oracle Database 12c and later.
- Using Oracle GoldenGate replication
You replicate the data from the non-CDB to a PDB. When the PDB becomes current with the non-CDB, you switch over to the PDB.
Creation of a PDB by Relocating
To relocate a PDB from one CDB to another, use either the
CREATE PLUGGABLE DATABASE ... RELOCATE statement or DBCA.
This technique has the following advantages:
- The relocation occurs with minimal downtime.
- The technique keeps the PDB being relocated open in read/write mode during the relocation, and then brings the PDB online in its new location.
You must create a database link at the target CDB, which is the CDB that will contain the relocated PDB. Also, the source PDB must use local undo data.
The following graphic depicts a PDB relocation.
Starting in Oracle Database 19c, you can relocate a remote PDB using DBCA in silent mode.
The following statement, which is issued at a target CDB, relocates
hrpdb from the source CDB to the target CDB:
CREATE PLUGGABLE DATABASE hrpdb FROM [email protected]_to_source RELOCATE;
Creation of a PDB as a Proxy PDB
A proxy PDB provides access to different PDB, called the referenced PDB, in a remote CDB.
Proxy PDBs enable you to aggregate data from multiple sources. A SQL statement submitted for execution in a proxy PDB executes within the referenced PDB.
A typical use case is a proxy PDB that references an application root replica. If multiple CDBs have the same application definition (for example, same tables and PL/SQL packages), then you can create a proxy PDB in the application container of the master application root. The referenced PDB for the proxy PDB is the application root in a different CDB. By running installation scripts in the master root, the application roots in the other CDBs become replicas of the master application root.
To create a proxy PDB, use the
CREATE PLUGGABLE DATABASE statement with the
FROM clause, which must specify a database link to the referenced PDB in the remote CDB, and the
AS PROXY clause.
Creation of a Proxy PDB
This example creates a proxy PDB named
pdb1. The referenced PDB is specified using a database link.
CREATE PLUGGABLE DATABASE pdb1 AS PROXY FROM [email protected]_link;