Multitenant Database Introduction

Multitenant Database Introduction


A Container database (CDB) is made up of the following containers:


There is one root container which stores the Oracle supplied metadata like the PL/SQL data dictionary packages and the common users. This root container is referred to as CDB$ROOT. One seed Pluggable Database (PDB) which is a system supplied template which can be used to create new PDB’s. This seed PDB is called PDB$SEED.


To find out if the database has been created as a CDB or not, just check the column called CDB in the view V$DATABASE.


Let’s check the ORACLE_SID:


There is just one SID; not one for each PDB. Now, let’s check for the processes “pmon”:


As you can see, the only instance running is CONA (the CDB). There is no instance for the PDB named PDB1. You can create as many of these PDBs on this CDB called CONA. There will be no additional instance. PDBs are simply hosted on the CDBs. So in effect these PDBs are like virtual machines running on a physical machine in a virtual machine context.


Since the CDB is the only real database, all the physical database components such as the Automatic Diagnostic Repository (ADR) is associated with it.


Let’s check the ADR using the ADRCI command line utility:


As you see from the output, there is only one ADR home – that for CONA (the CDB). There is no separate ADR for the PDBs.

You can check the containers (or PDBs) created in a database in a view named V$PDBS, which is new in Oracle Database 12c.

Note how the DBIDs are also different for each PDB. There are two striking oddities in this output:

  • There is no CON_ID of 1. There is a special container called the “root” container, known as CDB$Root that is created to hold the metadata. This container has the CON_ID of 1.
  • There is a PDB called PDB$SEED, which is something we didn’t create. There are new built-in functions to identify PDBs from their details without querying the V$PDBS view. Here is an example how to identify the container ID from the name:



And, here is how you can get the container ID from the DBID:

Operating on Specific PDBs


The next big question is considering the unusual nature of the PDBs (they are virtual inside a real database) how you can operate on a specific PDB.


Below are the different types:


  1. 1. Session Variable: You can set a session variable called container to the name of the PDB you want to operate on. First connect to the CDB as usual. Here is how I connected as the SYSDBA user:

  2. Now all commands in this session will be executed in the context of the PDB called PDB1. For instance suppose you want to shutdown the PDB named PDB1, you would issue:


Only the PDB called PDB1 will be shut down, other PDBs will not be affected. 


  1. 2. Service Name: When you create a PDB, Oracle automatically adds it as a service in the listener. You can confirm it by looking at the listener status:


The service “pdb1” actually points to the PDB called PDB1. It’s very important to note that that this is not a service name in initialization parameter of the database, as you can see from the service_names parameter of the database.


You can place that service name in an entry in the TNSNAMES.ORA file. Then you can connect to PDB1 using the connect string:



  1. Using TWO_TASK: A third way is by defining the TWO_TASK operating system variable to point to the PDB you want to connect to:
    [oracle@prosrv1 schema]$ export TWO_TASK=PDB1

And, then you can connect as usual without giving a connect string:



Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

Add Comment