This tutorial covers the steps to perform basic tasks on container databases (CDBs) and pluggable databases (PDBs).
Time to Complete
Approximately 45 minutes
This tutorial shows you how to:
- Connect to a CDB and to a PDB.
- Create a PDB from the seed PDB.
- Manage CDBs and PDBs.
- Start a CDB, understand the different open modes of PDBs, and shut down a CDB.
- Open and close PDBs.
- Change the name of a PDB.
- Manage the storage in a CDB and its PDBs.
- Manage permanent tablespaces.
- Manage temporary tablespaces.
- Manage the security in PDBs.
- Create common and local users.
- Create common and local roles.
- Grant common and local privileges.
- Drop PDBs.
Note: For readability, formatting was applied to some columns shown in the output.
Before starting this tutorial, you should:
- Install Oracle Database 12c
- Create one CDB and one PDB
- ORACLE_HOME: /u01/app/oracle/product/12.1.0
- TNS Listener port: 1521
- Container databases:
- SID: cdb1
- SID: cdb2
- Pluggable databases (in cdb1):
The environment used in the development of this tutorial is as follows:
Connecting to the CDB Root or to a PDB
Creating a CDB creates a service whose name is the CDB name. As
a side effect of creating a PDB in the CDB, a service is created
inside it with a property that identifies it as the initial
current container. The service is also started as a side effect
of creating the PDB. The service has the same name as the PDB.
Although its metadata is recorded inside the PDB, the invariant
is maintained so that a service name is unique within the entire
Creating a PDB from the Seed PDB
In this section, you create a PDB from the seed PDB. Each CDB
has a template PDB whose name is
Creating the OS Directory for the
New Data Files and Temp Files of the PDB
Before starting the PDB creation, create a destination directory for the data files.
Creating the PDB
Managing the CDB and the PDBs
In this section, you start the CDB and shut it down. You
also open and close the PDBs.
Managing the CDB
Managing the PDBs
Renaming a PDB
Managing Storage in a CDB and Its PDBs
Each container in a CDB stores data in its own data files and handles temporary data in its own temp files.
Managing Security in PDBs
- Common users are created from the root and are
automatically replicated in each PDB except the seed
PDB. Common users can connect to any PDB. The name
assigned to a common user must start with c##.
- Local users are created in a PDB they need to access.
Local users can only connect to the PDB where they are
created. They are not visible to the other PDBs of the
- Common roles are created from the root and are automatically replicated in each PDB except the seed PDB. The name assigned to a common role must start with c##.
- Common roles can be granted commonly: The grant
operation is replicated in each PDB except the seed
- Common roles can be granted locally: The grant operation is performed in the container where the operation takes place.
- Local roles are created in a PDB they need to access. Local roles can be granted locally only in the PDB where they are created. They are not visible to the other PDBs of the same CDB.
- Common privileges are automatically granted to the common grantee (user or role) in each PDB except the seed PDB.
- Local privileges are granted to a grantee (user or role) in a specific PDB.
Managing Common and Local Users
Each container in a CDB holds common and local users. Any user, common or local, can only exercise the granted privileges inside the specific container to which it is connected.
Managing Common and Local Roles
Each container in a CDB holds common and local roles.
Managing Common and Local
You can grant common and local privileges to common and
local users and roles. The privileges become common or
local based on how they are granted. They are common when
they are granted with the
When you drop a PDB, you can specify to keep or delete the data
files. Keeping the data files is required when you unplug a PDB
and want to plug it into another CDB (or the same CDB). The data
files are reused when plugging in the PDB.
Resetting Your Environment
Perform the following steps to reset your environment prior to repeating the activities covered in this OBE or starting another OBE.
In this tutorial, you learned how to manage basic tasks on container and pluggable databases, including creating PDBs from seed PDBs; managing tablespaces and security; and creating common and local users, roles, and privileges.
- To learn more about pluggable databases, refer to
additional OBEs in the Oracle Learning Library.
Curriculum Developers: Dominique Jeunot and Jean-François Verrier
To navigate this Oracle by Example tutorial, note the following:
- Hide Header Buttons:
- Click the title to hide the buttons in the header. To show the buttons again, click the title again.
- Topic List:
- Click a topic to navigate to that section.
- Expand All Topics:
- Click the button to show or hide the details for the sections. By default, all topics are collapsed.
- Hide All Images:
- Click the button to show or hide the screenshots. By default, all images are displayed.
- Click the button to print the content. The content that is currently displayed or hidden is printed.
To navigate to a particular section in this tutorial, select the topic from the list.