Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • OEM-Commnds Oracle
  • Adding addidional hard drive and attach it to a linux box. Linux/Unix
  • Important Solaris Commands Linux/Unix
  • Oracle 10g Installation/Applying Patches Tips Oracle
  • ORACLE_SID in sqlplus Oracle
  • Another Tuning Article for subheap of shared pool Oracle
  • replacing ^M character when passing files from Windows to Unix Linux/Unix
  • How to check current redo log progress redo_progress.sql Oracle
  • pvmehta.com SQL scripts
    Find which sessions is accessing object that prevent your session to have exclusive locks in Oracle Oracle
  • tuning commmand for cpu, ip and memory stats Linux/Unix
  • Import and export statements Oracle
  • nfs mount command Linux/Unix
  • Load SPM baseline from AWR Oracle
  • Export With Query Another Example. Oracle
  • How does one overcome the Unix 2 Gig file limit? Linux/Unix

find_pdbs.sql

Posted on 08-Apr-2026 By Admin

Understanding Oracle Multitenant: Querying PDB Status Across Instances

As an Oracle DBA working with Container Databases (CDBs), one of the most common tasks is checking the status of your Pluggable Databases (PDBs). Today I’ll share a useful script that provides a comprehensive view of all PDBs across all instances in your Oracle RAC environment.

The Power of gv$pdbs

The gv$pdbs view is a global view that shows information about all PDBs in a CDB across all instances in an Oracle RAC environment. This is particularly useful when you need to verify the status of PDBs consistently across all nodes.

The Script Explained

Here’s the script we’ll be using:

col inst_id format 99
col con_id format 99
col name format a30
col open_mode format a30
set lines 120 pages 200

SELECT inst_id, con_id, name, open_mode
FROM gv$pdbs
ORDER BY name, inst_id;

Let me break down what each part does:

  1. Column Formatting:
  2. col inst_id format 99: Formats the instance ID to display as 2 digits
  3. col con_id format 99: Formats the container ID to display as 2 digits
  4. col name format a30: Allocates 30 characters for the PDB name
  5. col open_mode format a30: Allocates 30 characters for the open mode

  6. Output Settings:

  7. set lines 120: Sets line width to 120 characters
  8. set pages 200: Sets page size to 200 lines

  9. The Query:

  10. Selects instance ID, container ID, PDB name, and open mode
  11. From the global view gv$pdbs
  12. Orders results by PDB name and instance ID

Sample Output

When you run this script, you’ll see output similar to:

INST_ID CON_ID NAME                           OPEN_MODE
------- ------ ------------------------------ ------------------------------
      1      2 PDB$SEED                       READ ONLY
      1      3 HR_PDB                         READ WRITE
      1      4 FINANCE_PDB                    READ WRITE
      2      2 PDB$SEED                       READ ONLY
      2      3 HR_PDB                         READ WRITE
      2      4 FINANCE_PDB                    MOUNTED

Why This Script is Useful

  1. Cross-Instance Visibility: Shows PDB status across all RAC instances
  2. Quick Status Check: Immediately identifies PDBs that aren’t in the expected state
  3. Consistent Formatting: Clean, readable output regardless of PDB name length
  4. Seed Database Included: Shows the PDB$SEED database which is important for PDB creation

Advanced Usage

For more detailed information, you could enhance this query with additional columns:

SELECT inst_id, con_id, name, open_mode,
       restricted, recovery_status, creation_time
FROM gv$pdbs
ORDER BY name, inst_id;

This adds information about restricted mode, recovery status, and creation time.

Conclusion

This simple but powerful script is a must-have in your Oracle DBA toolkit. It provides immediate visibility into your PDB environment across all RAC instances, helping you quickly identify any PDBs that might need attention.

What other PDB-related queries do you find most useful in your daily DBA work? Share your favorites in the comments!

Uncategorized

Post navigation

Previous Post: Creating a Container Database using dbaascli
Next Post: find_encr_wallet.sql

Related Posts

  • Creating a Container Database using dbaascli Uncategorized
  • find_encr_wallet.sql Uncategorized

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (398)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (150)
  • SQL scripts (346)
  • SQL Server (6)
  • Uncategorized (3)
  • Videos (0)

Recent Posts

  • pvm_pre_change.sql08-Apr-2026
  • find_encr_wallet.sql08-Apr-2026
  • find_pdbs.sql08-Apr-2026
  • Creating a Container Database using dbaascli08-Apr-2026
  • track_autoupgrade_copy_progress.sql01-Apr-2026
  • refre.sql for multitenant01-Apr-2026
  • prepfiles.sh for step by step generating pending statistics files10-Mar-2026
  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025
  • Postgres DB user and OS user.25-Dec-2025

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • DBA_HIST_SQLSTAT contents Oracle
  • MYSQL for Oracle DBA MYSQL
  • TNSNAMES entries details Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • sesswait.sql Oracle
  • Benefits and Usage of RMAN with Standby Databases Oracle
  • Configure ssh authentications for RAC Oracle
  • Vivek Tuning for Row Locks. Oracle

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme