A Pluggable Database (PDB) is a self-contained, portable collection of schemas, objects, and related database structures that resides within a larger Container Database (CDB) in Oracle's Multitenant Architecture. This architecture, introduced in Oracle Database 12c, allows multiple PDBs to share a single CDB's system resources (memory, processes, etc.) while maintaining data isolation and independent management capabilities.
Key Concepts of PDB
-
Container Database (CDB):
- A CDB is the top-level database that houses multiple PDBs. It contains the root container (CDB$ROOT) and optionally a seed PDB (PDB$SEED), which serves as a template for creating new PDBs.
- The root container stores shared metadata and system information used by all PDBs.
-
Pluggable Database (PDB):
- A PDB is a fully functional, self-contained database that resides within the CDB.
- Each PDB has its own:
- User schemas.
- Tablespaces.
- Metadata.
- Security policies.
-
Isolation:
- Each PDB operates independently from other PDBs in terms of security, schemas, and user management.
- However, all PDBs share the same database instance, including memory and background processes.
-
Portability:
- PDBs can be easily unplugged from one CDB and plugged into another, making it ideal for consolidating and migrating databases.
-
Seed PDB (PDB$SEED):
- A read-only template PDB used for creating new PDBs.
- It is automatically included in every CDB.
Advantages of PDBs
-
Database Consolidation:
- Multiple PDBs can run within a single CDB, reducing resource usage compared to running multiple standalone databases.
-
Ease of Migration:
- PDBs can be unplugged from one CDB and plugged into another, facilitating easy database migration.
-
Independent Management:
- Each PDB can be backed up, restored, and managed independently of other PDBs.
-
Resource Sharing:
- PDBs share memory and processes of the CDB, which reduces overhead and improves resource utilization.
-
Cost Efficiency:
- Ideal for consolidating databases in environments with Oracle Multitenant licensing, reducing operational costs.
Common Use Cases
-
Database Consolidation:
- Organizations consolidating multiple databases into a single infrastructure to reduce resource usage and licensing costs.
-
Development and Testing:
- Developers can create multiple isolated environments for testing within a single CDB.
-
Simplified Upgrades:
- Upgrading the CDB automatically applies to all PDBs.
-
Cloud and Multitenancy:
- Cloud service providers use PDBs to deliver Database-as-a-Service (DBaaS) to multiple customers, maintaining isolation.
Example: Viewing and Switching to a PDB
1. List All PDBs
To see all PDBs in a CDB:
SELECT name, open_mode FROM v$pdbs;
2. Switch to a PDB
To switch to a specific PDB, e.g., FREEPDB1:
ALTER SESSION SET CONTAINER = FREEPDB1;
3. Work Inside the PDB
Once connected, all operations will be scoped to the selected PDB.
Summary
A Pluggable Database (PDB) provides a way to manage and consolidate multiple databases within a single Oracle Database instance (CDB). It simplifies database management, reduces costs, and enhances flexibility for operations like migration and resource sharing.