Oracle Database Administrators often need to manage pluggable databases (PDBs) within a multitenant container database (CDB). The ALTER PLUGGABLE DATABASE command is a powerful tool for modifying the state and configuration of a PDB. This article explains common uses and syntax for this command.
Key Operations
- Open/Close a PDB: Use
ALTER PLUGGABLE DATABASE pdb_name OPEN;to open a PDB for access. To close it, useALTER PLUGGABLE DATABASE pdb_name CLOSE;. - Change State: Other states include
MOUNT,RESTRICTED, andREAD ONLY. For example,ALTER PLUGGABLE DATABASE pdb_name OPEN READ ONLY;. - Save/Discard State: You can save the current state with
ALTER PLUGGABLE DATABASE pdb_name SAVE STATE;so it persists across CDB restarts. To clear the saved state, useDISCARD STATE. - Modify Default Tablespace: Change the default tablespace for a PDB using
ALTER PLUGGABLE DATABASE DEFAULT TABLESPACE tbsp_name;.
Example Usage
-- Open a PDB
ALTER PLUGGABLE DATABASE salespdb OPEN;
-- Close a PDB
ALTER PLUGGABLE DATABASE salespdb CLOSE IMMEDIATE;
-- Save state
ALTER PLUGGABLE DATABASE salespdb SAVE STATE;
-- Change default tablespace
ALTER PLUGGABLE DATABASE salespdb DEFAULT TABLESPACE users;
Important Considerations
- Always ensure you are connected to the correct CDB or PDB context when executing these commands.
- Use
IMMEDIATEkeyword for faster shutdown of a PDB. - The
SAVE STATEcommand does not store the open mode (e.g., READ WRITE) but only whether the PDB was open or closed at shutdown.
Mastering these commands allows DBAs to efficiently manage pluggable databases in Oracle's multitenant architecture.