Chapter 13 · Multitenant Architecture: CDBs, PDBs, Services, Cloning, and Lifecycle

Create/Open/Close/Save State for PDBs and Service-Based Connection Management

Create or safely inspect PDB lifecycle state, preserve open mode with SAVE STATE, connect by service rather than SID, and verify that network success actually landed the session in the intended PDB.

Advanced120–140 minutesPDB state + service mapping labFREE/FREEPDB1 default services · optional OMF disposable PDBSYSDBA/SYSOPER scope explicitLast reviewed: August 2026

Learning outcomes

A maintenance restart completes successfully, but ServiceHub cannot connect. The listener is up, the CDB is open, and the operator can log in through the FREE service—yet the application PDB is mounted. Multitenant availability has two layers: the instance/CDB must be available, and the target PDB plus its service must be open/registered for the client workload.

01

Create a disposable seed-based PDB only when OMF/storage/privilege checks make the lab safe.

02

Change PDB open modes and verify runtime state through V$PDBS/DBA_PDBS.

03

Use SAVE STATE and DBA_PDB_SAVED_STATES to preserve intended PDB open mode across CDB restarts.

04

Connect clients by PDB service name and verify V$SERVICES/service-to-PDB mapping.

05

Distinguish instance SID, CDB/root service, PDB service, listener registration, and actual session container.

Generation-time baseline and entitlement boundary

Mandatory work targets Oracle AI Database Free 26ai, reviewed against RU 23.26.3, SQL Developer 26.2, and SQLcl 26.2.1. The August 2026 Licensing Information manual lists Oracle Multitenant as included in Free with a maximum of 16 PDBs, although the practical number can be lower because Free is capped at 2 foreground CPU cores, 2 GB RAM, and 12 GB user data. Free permits one installation per logical environment and receives no Oracle patches or Support service requests. The course baseline CDB is FREE and the default application PDB/service is FREEPDB1. Administrative PDB lifecycle commands require root/PDB-specific administrative privileges; application SQL remains in FREEPDB1 or an explicitly created disposable PDB.

1. Creation starts mounted; first READ WRITE open completes integration

A new PDB created from PDB$SEED starts mounted with status NEW. Oracle requires the first open in READ WRITE mode to complete integration and transition the PDB status to NORMAL. Creation also establishes a default service with the same name as the PDB.

sql · preflight before optional disposable-PDB creation
SHOW CON_NAME-- Must be CDB$ROOT.SELECT value AS db_create_file_destFROM v$parameterWHERE name='db_create_file_dest';SELECT COUNT(*) AS current_pdbsFROM dba_pdbs;SELECT name,open_mode,total_sizeFROM v$pdbsORDER BY con_id;

The optional creation path below assumes Oracle Managed Files (OMF): DB_CREATE_FILE_DEST is non-null, enough Free user-data/storage capacity remains, and you are connected with CREATE PLUGGABLE DATABASE/SYSDBA authority. If OMF is not configured, do not guess file paths; continue the mandatory state/service lab with FREEPDB1.

2. Optional Free local PDB creation

sql · SQLcl/SQL*Plus — prompt rather than hard-code the PDB admin password
ACCEPT sh13_pwd CHAR PROMPT 'Password for SH13ADMIN: ' HIDECREATE PLUGGABLE DATABASE sh13lab  ADMIN USER sh13admin  IDENTIFIED BY "&sh13_pwd";ALTER PLUGGABLE DATABASE sh13lab OPEN READ WRITE;SELECT pdb_name,statusFROM dba_pdbsWHERE pdb_name='SH13LAB';SELECT name,open_mode,restrictedFROM v$pdbsWHERE name='SH13LAB';

Do not run the creation command if OMF is absent or Free capacity is tight. A non-OMF deployment needs an intentionally designed FILE_NAME_CONVERT/PDB_FILE_NAME_CONVERT strategy tied to actual storage.

3. Open/close state is independent of the CDB being open

sql · root-level lifecycle operations
ALTER PLUGGABLE DATABASE FREEPDB1 CLOSE IMMEDIATE;SELECT name,open_modeFROM v$pdbsWHERE name='FREEPDB1';-- MOUNTEDALTER PLUGGABLE DATABASE FREEPDB1 OPEN READ WRITE;SELECT name,open_modeFROM v$pdbsWHERE name='FREEPDB1';-- READ WRITE

CLOSE IMMEDIATE terminates/disconnects affected PDB workload; schedule it like downtime. Do not run it while the ServiceHub application is active unless this is a disposable lab instance.

4. SAVE STATE makes restart intent explicit

Without saved state, PDB behavior after instance/CDB startup can differ from application expectations. SAVE STATE records the current open mode for future instance restarts. DBA_PDB_SAVED_STATES is the evidence that the state was preserved; it is not proof that a future startup actually succeeded.

sql · save and verify desired state
ALTER PLUGGABLE DATABASE FREEPDB1 OPEN READ WRITE;ALTER PLUGGABLE DATABASE FREEPDB1 SAVE STATE;SELECT  con_name,  instance_name,  state,  restrictedFROM dba_pdb_saved_statesWHERE con_name='FREEPDB1';
sql · rollback saved-state intent if the lab requires manual opening
ALTER PLUGGABLE DATABASE FREEPDB1 DISCARD STATE;

After testing DISCARD STATE, restore the course baseline with SAVE STATE if automatic PDB opening is expected.

5. Service names route sessions to PDBs; a SID identifies an instance

In multitenant client configuration, use a service associated with the PDB. The Oracle AI Database Free defaults are FREE for root and FREEPDB1 for the default PDB. Each new PDB gets a default service with the same name. An Oracle System Identifier (SID) identifies an instance; it is not a PDB routing key.

sql · database-side service mapping
SELECT  name,  network_name,  pdb,  enabledFROM v$servicesORDER BY name;
text · OS/listener evidence
lsnrctl status

lsnrctl status proves what services the listener currently advertises. It does not prove that application credentials are valid or that a session lands in the desired container after connecting.

6. Deliberately wrong: connect successfully to FREE and assume it is ServiceHub

sql · wrong target can still authenticate successfully
sql system@//localhost:1521/FREESELECT SYS_CONTEXT('USERENV','CON_NAME') AS con_nameFROM dual;-- CDB$ROOT

A root connection can be operationally powerful, so this is not merely a query-result error. The repair is to use the PDB service and verify container identity.

sql · correct service-based application/admin connection
sql sh13admin@//localhost:1521/SH13LAB-- or the course PDB:-- sql servicehub_owner@//localhost:1521/FREEPDB1SELECT  SYS_CONTEXT('USERENV','CON_NAME') AS con_name,  SYS_CONTEXT('USERENV','SERVICE_NAME') AS service_nameFROM dual;

7. Service design in production

The PDB default service is convenient for administration and labs, but production applications should use purpose-built services when workload routing, drain behavior, failover, connection-pool configuration, or workload management needs distinct identities. Service management differs between single-instance and Oracle RAC/Grid Infrastructure deployments; do not copy srvctl procedures into a standalone Free installation.

8. Optional cleanup for SH13LAB

sql · run only if this lesson created SH13LAB
ALTER SESSION SET CONTAINER=CDB$ROOT;ALTER PLUGGABLE DATABASE sh13lab CLOSE IMMEDIATE;DROP PLUGGABLE DATABASE sh13lab INCLUDING DATAFILES;

Never use INCLUDING DATAFILES on a PDB whose files or backups you still need. Verify the PDB name and container before the drop.

9. Production judgment

Treat CDB availability, PDB open state, service registration, listener reachability, credential success, and session container identity as separate checkpoints. Save PDB state intentionally and monitor it after maintenance. Use service names for PDB clients, not instance SID assumptions.

No pack or COMPATIBLE change is required. Optional PDB creation consumes Free's finite user-data/storage budget. Lesson 3 now moves a PDB through cloning and portability workflows where file ownership, local undo, compatibility, service collisions, and topology become decisive.

Check your understanding

  1. What state is a newly created PDB in before its first READ WRITE open?
  2. What does SAVE STATE persist?
  3. Why should a PDB client connect through a service instead of a SID?
  4. What does V$SERVICES.PDB tell you?
  5. When should the optional SH13LAB creation be skipped?
Review the answers

It is mounted with lifecycle status NEW; the first READ WRITE open completes integration to NORMAL.

It preserves the PDB's intended open state for subsequent CDB/instance startup.

A service maps a client workload to a PDB; a SID identifies an instance and does not select the PDB.

It identifies the PDB associated with that service; NULL indicates a service not associated with a PDB/root routing.

Skip it when OMF/file placement is not intentionally configured, privileges are insufficient, or Free storage/user-data capacity is tight.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.