Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Process Map for CPU and Memory for OS processes Linux/Unix
  • xargs use Linux/Unix
  • cur_sql.sql Oracle
  • Vivek’s egrep commands to trace problem. (on linux x86-64) Linux/Unix
  • scripts to take listener.log backup Linux/Unix
  • Find_stale_dr.sql finding stale physical DR.. Oracle
  • find the files that are 1 day old. Linux/Unix
  • CTAS with LONG Column for 9i and higher Oracle
  • catting.sh Linux/Unix
  • Multiple listeners Oracle
  • temp_use.sql diplays usage of temp ts Oracle
  • create user with unlimited quota Oracle
  • run this before doing any dbchange pvm_pre_change.sql Oracle
  • Display the top 5 salaries for each department using single SQL Oracle
  • checking redhat linux version 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

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

Categories

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

Recent Posts

  • 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
  • Trace a SQL session from another session using ORADEBUG30-Sep-2025

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • database trigger failing Oracle
  • Implementing Listener Security Oracle
  • Good Oracle Architecture In Short and point to point Oracle
  • Unix command for system configuration Linux/Unix
  • get_vmstat.ksh Linux/Unix
  • How to find password change date for user Oracle
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • changing kernel parameter in Oracle Enterpise Linux Linux/Unix

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme