Essential toolkit for Oracle Database Administrators to automate daily monitoring, audit schema integrity, and track system health. This repository serves as a professional portfolio of high-performance SQL scripts and in-depth technical guides for enterprise-level database management.
The Definitive Guide to DBA_REGISTRY_SQLPATCH
A deep dive into verifying database patch levels in managed cloud environments. This guide is essential for developers and DBAs working on Oracle 19c RDS where standard OS access (opatch) is restricted.
- Key Topics:
DBA_REGISTRY_SQLPATCHvs legacy views, decoding NJ flags, and XML metadata extraction. - Tools: Advanced SQL and XQuery (
XMLTABLE) for data dictionary auditing.
The Definitive Guide to Cross-Schema Dependency Validation
An in-depth architectural guide on tracking system degradation and deployment consistency across distinct structural boundaries. This article establishes an optimal framework for isolating operational variations between target application schemas following complex database upgrades.
- Key Topics: Decoupling cascading metadata changes, optimizing dictionary join paths, and automating baseline consistency validation.
- Tools: Analytic set operations and metadata extraction via
DBA_OBJECTSwrappers.
Declarative Directory Purging via JSON-Driven Regex and SQL
A senior-grade blueprint for implementing declarative, automated file retention pipelines within managed cloud databases. This framework isolates volatile retention metadata from underlying procedural processing loops, establishing a modern approach to cloud database file system maintenance.
- Key Topics: Mitigating PaaS space exhaustion errors, case-sensitive matching strategies, and parsing double-escaped (
\\) regular expressions. - Tools: Set-based
CROSS APPLYlateral joins,JSON_TABLEpolicy metadata projection, andDBMS_SCHEDULERorchestration.
High-Authority Script for Schema Integrity Audits
This diagnostic utility is crucial for identifying INVALID objects across different Oracle environments or application schemas (e.g., comparing ADMIN vs. CUSTOMER). It helps DBAs verify deployment success and identify broken dependencies after major patches or upgrades.
- Primary Use Case: CI/CD deployment validation, database migration auditing, and schema consistency checking.
- Key Features:
- Tracks
INVALIDstatus for Views, Packages, Procedures, and Functions. - Compares object metadata including
CREATEDandLAST_DDL_TIME. - Optimized for Oracle 12c, 19c, 21c, and 23c architectures.
- Tracks
High-Impact Utility for SQL Patch Metadata Reporting
This utility leverages Analytic Functions and XQuery to parse the database's internal XML descriptors. It identifies the Patch RU Level while ignoring failed attempts, providing a clean audit of the current database software state.
- Primary Use Case: Verifying Patch Release Updates (RU) and internal component health in AWS RDS or on-premise environments.
- Key Features:
- Extracts ruVersion and Patch Component Impact from
XMLTYPEdescriptors. - Resolves Patch Registry history using
ROW_NUMBER()for a deduplicated view. - Essential for identifying JVM and CATPROC patch states.
- Extracts ruVersion and Patch Component Impact from
Unified Storage Diagnostics and Declarative Purge Preview
This high-performance utility enables DBAs to audit underlying file system allocation inside managed cloud instances where direct OS access is restricted. It calculates exact directory metrics and processes embedded JSON parameters to provide a secure "Dry-Run" preview of files eligible for deletion under current lifecycle policies.
- Primary Use Case: Proactive storage capacity reporting, identifying hidden disk space leaks, and pre-execution validation of automated purge cycles in Amazon RDS for Oracle.
- Key Features:
- Aggregates file counts and sizes across dynamic in-memory collections using a lateral
CROSS APPLYjoin. - Implements a case-sensitive metadata evaluation layer utilizing
JSON_TABLEto safely preview target cleanup candidates. - Utilizes
dbms_xplan.format_sizeto output complex byte allocations into highly readable execution summaries.
- Aggregates file counts and sizes across dynamic in-memory collections using a lateral
To ensure the successful execution of these scripts, verify the following:
- Database Permissions: Users must have
SELECTprivileges onDBA_OBJECTS. If administrative access is restricted, replaceDBA_OBJECTSwithALL_OBJECTSin the script. - Oracle Version: Full compatibility with Oracle Database 11g through 23c.
- Environment: Access to source and target schemas within the same database instance.
- Clone the repo:
git clone https://github.com/orclkit/oracle-dba-toolkit - Execution: Run scripts via SQL Developer, TOAD, or SQL*Plus.
- Configuration: Update the
OWNERfilter in theWHEREclause:src.owner = 'SOURCE_SCHEMA'trg.owner = 'TARGET_SCHEMA'
| Issue | Potential Cause | Recommended Fix |
|---|---|---|
| Empty Result Set | Status mismatch | Ensure source objects are in INVALID status before running. |
| ORA-00942 | Missing Privileges | Use ALL_OBJECTS or request SELECT_CATALOG_ROLE. |
| No Matches Found | Case Sensitivity | Schema names must be UPPERCASE (e.g., 'ADMIN', not 'admin'). |
| Performance Lag | Dictionary Size | Filter by OBJECT_TYPE (e.g., 'PACKAGE') to reduce join overhead. |
| ORA-19279 | XML Sequence Mismatch | Ensure the query uses string-join() for patches affecting multiple components. |
| Empty "target_ru" | Legacy Patches | Older patches in the registry (pre-12c style) may lack XML attributes; check description instead. |
| ORA-01031 | Insufficient Privileges | User requires SELECT on DBA_REGISTRY_SQLPATCH (usually granted via DBA role). |
| Inaccurate Version | Inventory Sync Delay | On RDS, wait 30-60 minutes after maintenance for the XML descriptor to fully populate. |
scripts/: Production-ready SQL utilities for maintenance and auditing.article/: In-depth guides on Oracle source extraction and DBA best practices.images/: Technical diagrams and query result demonstrations.
Expert in Oracle Database Administration, specializing in automation, high-availability, and performance tuning.
Star this repo if these scripts help your daily workflow!