Step-by-Step: Check CDB and PDB Status

To check the status of an Oracle Container Database (CDB) and its Pluggable Databases (PDBs), you can use the following SQL commands in SQL*Plus, SQL Developer, or any Oracle client:

A Container Database (CDB) is the core database structure in Oracle’s Multitenant Architecture, introduced in Oracle 12c and enhanced in later versions like 23c.

1. Connect to the CDB as a privileged user
Use SQL*Plus or SQL Developer:

# sqlplus / as sysdba

2.Check the CDB (instance) status
SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V$INSTANCE;
STATUS: Should be OPEN
DATABASE_STATUS: Should be ACTIVE

3. Confirm you’re in the root container (CDB$ROOT)
SHOW CON_NAME;
If the result is CDB$ROOT, you are in the correct context to check all PDBs.

4. Check all PDBs and their status
SELECT NAME, OPEN_MODE, RESTRICTED, CON_ID FROM V$PDBS;

Example Output:

NAME: PDB name
OPEN_MODE: Status like READ WRITE, MOUNTED, etc.
RESTRICTED: Whether restricted session is enabled
CON_ID: Container ID



5. Open all PDBs if needed

To open all PDBs:

ALTER PLUGGABLE DATABASE ALL OPEN;
To open a specific PDB:

ALTER PLUGGABLE DATABASE HR_PDB OPEN;


6. Switch to a specific PDB to work inside it
ALTER SESSION SET CONTAINER = HR_PDB;
SHOW CON_NAME;
Now you are operating inside HR_PDB.



Yorum bırakın