Oracle Database Administration II study materials
Oracle Database Administration II study resources

Oracle Database Administration II: CDB and PDB Management

Oracle Database Administration II · Work through your exam, one topic at a time.

All guide sections

CDB and PDB Management

This domain tests the multitenant container model: what is shared, what is local to a PDB, how users and privileges differ between root and PDB, and how PDBs are opened and navigated.

Architecture

A container database (CDB) has one root (CDB$ROOT), one read-only seed (PDB$SEED), and one or more pluggable databases (PDBs). In Oracle 12.2 and later, application containers and application seeds can also exist. All containers share one instance, one SGA, background processes, redo logs, and the control file. Each PDB has its own SYSTEM and SYSAUX tablespaces and, with local undo mode, its own undo tablespace. V$CONTAINERS, CDB_PDBS, and DBA_PDBS show containers and their CON_ID values; SYS_CONTEXT('USERENV','CON_NAME') shows the current container.

Users and privileges

Common users are created in the root, must begin with the common user prefix (C## by default), and can connect to any PDB where they have privileges. Grants made with CONTAINER=ALL apply across containers. Local users are created inside a PDB and exist only there. A common user can be given SET CONTAINER to switch between PDBs; local users cannot switch containers.

Open modes and services

A PDB can be MOUNTED, READ ONLY, or READ WRITE. Use ALTER PLUGGABLE DATABASE pdb OPEN, CLOSE IMMEDIATE, or SAVE STATE so the PDB reopens after a CDB restart. PDB$SEED is never opened read-write. Services connect sessions to a specific PDB.

Worked example

Create a common administrator in the root: CREATE USER c##ops IDENTIFIED BY ... CONTAINER=ALL; GRANT CREATE SESSION, SET CONTAINER TO c##ops CONTAINER=ALL;. Connect as c##ops, run ALTER SESSION SET CONTAINER=sales_pdb, and create a local application user there. The local user cannot be used from another PDB, while the common user can switch containers.

Traps

Creating a root user without the common prefix fails unless the prefix was changed. CONTAINER=ALL grants affect every container, including future PDBs. A PDB cannot be opened when the CDB is not open. Do not confuse V$PDBS with V$CONTAINERS; only the latter includes the root and seed.