Oracle Database Health Check Scripts

Tools and Scripts for Oracle Database Health Checks and Diagnostics

Businesses rely heavily on their databases to efficiently manage, store, and process large amounts of crucial information. While Oracle databases are known for their robustness, like any other complex system, they require continuous maintenance and monitoring to ensure peak performance and avoid unexpected issues.

For me, a general rule of thumb is to address tomorrow’s problems before they arise, while ensuring that today’s problems were resolved yesterday. This proactive mindset is essential for any Database Administrator (DBA).

That’s where proactive database health checks come into play. By definition, proactive health checks are actions of observation, analysis and correction of impending issues that might later scale to larger serious problems. This blog post provides a discussion on some of the tools and scripts that may become indispensable in handling database health.

You may already be familiar with many of these tools, but some will likely be new to you. I’ll provide a catalog without going into detail.

AHF Insights
AHF Insights is the latest advanced suite of tools designed to autonomously maintain the health and performance of Oracle database systems. It provides deeper diagnostic insights into Oracle diagnostic collections gathered by AHF utilities, including Oracle EXAchk/ORAchk, Oracle Trace File Analyzer, Exawatcher, and Cluster Health Monitor.

ORACHK / EXACHK
ORACHK / EXACHK is the number one free, lightweight, and non-intrusive health check framework for Oracle software and hardware components. It helps identify and address factors affecting Oracle compliance, stability, and performance. It includes numerous checks at the database, cluster, and OS levels. Previously a separate tool, it is now part of AHF (Autonomous Health Framework), which has been shipped with Oracle Grid Infrastructure since version 11.2.0.4. Its default autostart_client scheduled runs provide data for AHF Insights.

OSWatcher / ExaWatcher Utility
This utility collects and archives operating system and network metrics that help diagnose performance issues. It also provides graphical analysis tools. I have a blog post detailing how it can be used for: “Troubleshooting Oracle Clusterware Node Evictions and Reboot Problems.

Procwatcher
Procwatcher is a tool to examine and monitor Oracle database and/or clusterware processes at an interval. The tool will collect stack traces of these processes using Oracle tools like oradebug short_stack and/or OS debuggers like pstack, gdb, dbx, or ladebug and collect SQL data if specified. It can be used to proactively monitor shared pool memory allocation if there are ORA-4031 errors or other problems. You may refer to “How To Troubleshoot Database Contention With Procwatcher (Doc ID 1352623.1)” and “How To Troubleshoot ORA-4031’s and Shared Pool Issues With Procwatcher (Doc ID 1355030.1)” for more information.

TFA
TFA collects and packages diagnostic data, primarily used for creating incident packages for Oracle Support and troubleshooting ORA errors. SRDC (Service Request Data Collection) packages are collected with it. For example, to diagnose Oracle Text Performance Issues, you can use the tfactl diagcollect -srdc dbtextissue command to collect all the required information to share with the Oracle Support Team. As of February 2025, there are 385 different documents in the catalog “Oracle Catalog: Service Request Data Collections (SRDCs) for all Products and Services (Doc ID 51.2).” Since the UI is not self-guiding, I will explain how to access these 385 documents. Database-related documents can be found under the Hardware Tab. After clicking the Hardware tab, click “Show All” in the upper right corner.

There is also another link ” Oracle Catalog: Dynamic Toolbox – Diagnostic Tools, Scripts, and Analyzers for All Product and Services (Doc ID 52.2)” contains these documents and much more.

tfactl summary option
This option worths mentioning. This TFA flag/function offers a high-level, real-time status summary of your entire database environment. It provides detailed information about CRS, ASM, ACFS, Database, Patching Information, Network, Listeners, and Operating System. Refer to Prashant Dixit‘s blog post – “SUMMARY, my favorite Trace File Analyzer (TFA) command” for more information about it.

These four tools, along with TFA (Trace File Analyzer), which collects and packages diagnostic data, are all included with AHF and can be downloaded from “Autonomous Health Framework (AHF) – Including Trace File Analyzer and Orachk/Exachk (Doc ID 2550798.1)

ADRCI Command-Line Utility
The ADR Command Interpreter (ADRCI) is a command-line utility that allows you to investigate problems, view health check reports, and package first-failure diagnostic data. It utilizes the Automatic Diagnostic Repository (ADR) as its data source. For more information about it, refer to Oracle Database Administrator’s Guide – 9.Diagnosing and Resolving Problems.

CVU (Cluster Verification Utility – cluvfy)
CVU can also be used to verify the readiness and health of an Oracle Clusterware or Real Application Clusters (RAC) environment. By default the CVU resource (ora.cvu) in Oracle Clusterware is configured to run every 6 hours controlled by “RUN_INTERVAL”.

DBSAT (Database Security Assessment Tool)
DBSAT checks for common database security issues and best practices while also providing insights into sensitive data and high-privileged users. It produces an output format similar to ORACHK. Unlike other tools, DBSAT does not require a traditional installation: it is a standalone tool provided as a ZIP package that you simply extract and run. It can be downloaded from MOS Note: Oracle Database Security Assessment Tool (DBSAT) (Doc ID 2138254.1)

The Hang File Generator(HANGFG)
HANGFG (Hang File Generator) is a series of Unix shell scripts designed to automate the generation and collection of hanganalyze and systemstate trace files. It can also be considered a post-mortem analysis tool. HANGFG generates and collects hang trace files based on the impact of collecting diagnostic traces on a system that is already in a degraded state. The decision on what level of impact the user can afford is left up to the user when running HANGFG, as the level of impact is passed in as an argument to the tool. However, HANGFG can also make this decision automatically if the user selects light or medium impact (option 1 or 2) as an argument. HANGFG is RAC-aware and can run in either a RAC or non-RAC environment.Download of HANGFG is available through “HANGFG User Guide (Doc ID 362094.1)” and can be downloaded as a tar file. The user can then unarchive the tar file to the directory where HANGFG is to be installed.

Oracle OLAP
This script will provide output to show the overall health of the Oracle Workspace Manager component. It can be downloaded from MOS Note: Script OLAPHCDR.SQL: OLAP Health-Checks and Diagnostics Reports (Doc ID 2079036.1)

APEX
There is a script which will help to verify the status of the APEX installation. The output also helps DB objects needed to support the Apex installation. It can be downloaded from MOS Note: SRDC – Collect Installation Verification Script / Health Check for Apex (Doc ID 2036107.1)

Oracle Workspace Manager
This script was developed by the Server Technologies (ST) Center of Expertise (CoE). It gathers a set of pre-defined health checks across the entire OLAP (Online Analytical Processing) setup within the system. It can be downloaded from MOS Note: Oracle Workspace Manager Health Check (Doc ID 1906147.1)

Oracle Text
This script will provide output to show the overall health of the Oracle Text component. It can be downloaded from MOS Note: Oracle Text Health Check (Doc ID 823649.1)

Oracle Spatial
This script will provide output to show the overall health of the Oracle Spatial component. It can be downloaded from MOS Note: Oracle Spatial Health Check (Doc ID 800725.1)

Oracle Java Virtual Machine (OJVM)
OJVM is generally installed by default in a database and can be checked by querying dba_registry view. (SELECT version, status FROM dba_registry WHERE comp_id=’JAVAVM’)

Oracle JSON DB/SODA DB Health-Check Script
This script checking for the current status of JSON DB and SODA DB components, makes recommendations based on current settings and checks if the components are being used.It can be downloaded from MOS Note: JSON DB and SODA DB Health-Check Script (Doc ID 2212664.1)

As Oracle Multimedia (ORDIM), Oracle Warehouse Builder (OWB), and Oracle Locator have been desupported starting with Oracle 19c, I did not include them.

The Automatic Workload Repository (AWR) is the primary guide for diagnosing and resolving database performance issues, including SQL statement performance.

oradebug
oradebug is a command-line utility in Oracle used for debugging and troubleshooting the Oracle database, utilizing a numeric events tracing system (Oracle’s kernel service debugging mechanism). For more information about oradebug, refer to Tanel Poder’s ‘ORADEBUG DOC‘ page.

Sayan Malakshinov informed me about the HTML version of the ORADEBUG help documentation he built. Since ORADEBUG lacks detailed documentation (only some limited internal documentation is available) his guide serves as a valuable resource. You may also refer to the examples provided in his blog post, “Oracle Diagnostic Events — Cheat Sheet.”

There are various types of events available for troubleshooting, with the most commonly used trace events being

10046 – Captures wait events and bind variable values for detailed SQL execution analysis.
10053 – Provides query optimizer decision-making insights, useful for understanding execution plans.

Additionally, TKPROF is a powerful tool used to format Oracle trace files. It processes raw trace data and provides a structured output with execution statistics, wait events, and performance metrics for SQL statements.

SQL Repair Advisor – DBMS_SQLDIAG
SQL Repair Advisor has been available since Oracle 11g to help diagnose and fix valid SQL statements that fail with critical errors at runtime. The advisor performs a diagnostic operation on the statement and may provide a patch to repair it. It is accessible through Enterprise Manager and is facilitated by the DBMS_SQLDIAG package, which is also used for creating SQL patches.

VERSION_RPT
Version_rpt is a script that can be used for investigating child cursors. Script’s latest version is available in the link. The function generates a summary report from the v$sql_shared_cursor view, providing additional diagnostic details based on the reason code. It counts all versions with a ‘Y’ in any column and identifies those where all columns contain ‘N’. More information is available on High SQL Version Counts – Script to determine reason(s) (Doc ID 438755.1). A sample output is available on my blog post “Child Cursors: BIND_MISMATCH, BIND_LENGTH_UPGRADEABLE and BIND_EQUIV_FAILURE

SQLHC – SQL HEALTH CHECK
The SQL Tuning Health-Check Script (SQLHC) is a tool provided by Oracle that analyzes the environment in which a specified SQL statement runs. It examines Cost-Based Optimizer (CBO) statistics, schema object metadata, configuration parameters and other factors that may impact performance. SQLHC is free and does not require a license. However, if the Diagnostic or Tuning Pack is installed, SQLHC will request permission to determine whether these packs are licensed, as it can utilize data from AWR reports. When executed with a specific SQL_ID, SQLHC generates an HTML report summarizing the results of various health checks for the SQL statement.

Oracle SQL Health Check
SQL Health Check (SQLHC)

For downloading SQLHC and accessing more details, refer to MOS Note: SQL Tuning Health-Check Script (SQLHC) (Doc ID 1366133.1) and MOS Note: FAQ: SQL Health Check (SQLHC) Frequently Asked Questions (Doc ID 1417774.1).

SQLTXPLAIN – also known as SQLT
SQLT is a PL/SQL-based tool developed by Carlos Sierra that takes a single SQL statement as input and generates a ZIP file containing comprehensive diagnostic information. This package includes execution plans, Cost-Based Optimizer (CBO) statistics, schema object metadata, and various configuration details to assist in SQL performance tuning and troubleshooting.

SQLT is a far more advanced tool than SQLHC. While it includes similar checks, it provides significantly broader functionality. SQLHC serves as a quick health check for a SQL statement, acting as a subset of SQLT but without leaving a database footprint. SQLT, on the other hand, offers in-depth SQL tuning capabilities, making it a powerful tool for performance analysis. However, leveraging SQLT effectively requires some level of expertise.

For downloading SQLT and accessing more details, refer to “All About the SQLT Diagnostic Tool (Doc ID 215187.1)

SQLdb360
SQLdb360 is a “free to use toolset” to perform an initial assessment of an entire Oracle database or a particular SQL statement. SQLdb360 is made of two independent tools, eDB360 (database-wide analysis) and SQLd360 (individual SQL analysis). You can access its Github repository for downloads and the README file.

Materialized Views Health-Checks and Diagnostics Reports
The mvhcdr.sql script performs some health-checks around Materialized Views. It also generates some html and csv reports to diagnose Materialized Views issues. These diagnostics reports are based mainly on static SYS views. This script installs nothing on the database, and updates nothing. It can be downloaded from MOS Note: Script mvhcdr.sql: Materialized Views Health-Checks and Diagnostics Reports (Doc ID 1517362.1)

Parallel Execution Health-Checks and Parallel Execution Health-Checks and Diagnostics Reports
The pxhcdr.sql script performs a set of pre-defined health-checks around parallel execution setup system-wide and generates some html reports to diagnose PX issues. These diagnostics reports are based mainly on PX dynamic and static views. This script installs nothing on the database, and updates nothing. It can be downloaded from MOS Note: Script PXHCDR.SQL: Parallel Execution Health-Checks and Diagnostics Reports (Doc ID 1460440.1)

RAC Diagnostic Information (racdiag.sql)
This script is intended to provide a user friendly guide to troubleshoot RAC hung sessions or slow performance scenerios and includes information to gather a variety of important debug information to determine the cause of a RAC hung sessions or slow performance. It can be downloaded from MOS Note: Script to Collect RAC Diagnostic Information (racdiag.sql) (Doc ID 135714.1)

DRM Information (drmdiag.sql)
The drmdiag.sql is a script to collect information related to DRM (Dyanamic Resource Re-mastering), particularly for troubleshooting “gcs drm freeze in enter server mode” wait events.  It can be downloaded from MOS Note: Script to Collect DRM Information (drmdiag.sql) (Doc ID 1492990.1)

DBMS_HM Package
DBMS_HM is an Oracle package used for performing health checks on an Oracle database. It stands for Database Health Monitor, and the package provides a set of built-in procedures that help assess the database’s health and performance. By running health checks using DBMS_HM, database administrators can monitor various aspects of database performance and configuration. These are the checks can be run. Refer to the related documents page (PL/SQL Packages and Types Reference – Oracle Database Release 19) for more information.

DBMS_HM is an Oracle package used to perform health checks on an Oracle database. It stands for Database Health Monitor, and it provides a set of built-in procedures to assess the database’s health and performance. By using DBMS_HM to run health checks, database administrators can monitor various aspects of database performance and configuration. These checks can be executed to detect potential issues. For more information, refer to the related documents page in the ‘PL/SQL Packages and Types Reference – Oracle Database Release 19′.

Data Dictionary Health Check
The hcheck.sql script is a lightweight, read-only script that checks the health of the data dictionary and detects orphaned tables and indexes left in the dictionary. It verifies the consistency of selected dictionary relationships and identifies certain known issues; though some reported problems may be normal and expected. This script is primarily intended for use under the guidance of Oracle Support. It has been available since 8.1.7.4 and can be downloaded from MOS Note: hcheck.sql – Script to Check Data Dictionary for Known Problems (Doc ID 136697.1).

The good news is that for databases version 19.22 and later, performing a dictionary health check no longer requires downloading the hcheck.sql script. Instead, you can use the DBMS_DICTIONARY_CHECK package. Its usage is as simple as shown below. It also provides guidance to the related support document for solutions to your problems, warnings, errors, etc. Here is a sample run output.

In this sample output, we see some objects (parent object ID P_OBJ#) that have a dependent object ID D_OBJ#, where the dependent timestamp (P_TIMESTAMP) does not match the parent timestamp (STIME). We followed My Oracle Support Note 1361045.1 to resolve the issue. Specifically, we compiled 63 public synonyms, and the underlying issue was resolved.

What is good about DBMS_DICTIONARY_CHECK is that it is self guiding, for each specific case you will encounter there is a support document you may refer to. Here is the list.

LobNotInObj: Checks if a LOB segment is not in OBJ$ (My Oracle Support Note 1360208.1)
OIDOnObjCol: Checks if an object type column is not in OID$ (My Oracle Support Note 1360268.1)
SourceNotInObj: Checks if an entry in SOURCE$ is not in OBJ$ (My Oracle Support Note 1360233.1)
While running the SourceNotInObj procedure, optionally, you can use the repair option to resolve inconsistencies. Valid values: TRUE|FALSE. Default: FALSE.
IndIndparMismatch: Checks for index name mismatch between partitions (My Oracle Support Note 1360285.1)
InvCorrAudit: Checks for invalid AUDIT$ entries (My Oracle Support Note 1360489.1)
OversizedFiles: Checks for oversized database files (My Oracle Support Note 1360490.1)
PoorDefaultStorage: Checks tablespace default storage clauses (My Oracle Support Note 1360493.1)
PoorStorage: Checks objects storage clause (My Oracle Support Note 1360496.1)
PartSubPartMismatch: Checks valid partition methods (My Oracle Support Note 1360504.1)
TabPartCountMismatch: Checks invalid data between OBJ$-PARTOBJ$ and TABPART$ (My Oracle Support Note 1360514.1)
TabComPartObj: Checks that the composite partition has a valid entry in OBJ$ (My Oracle Support Note 1360515.1)
Mview: Check invalid entries for materialized view (My Oracle Support Note 1360517.1)
ValidDir: Checks that the directory object has valid entries (My Oracle Support Note 1360518.1)
DuplicateDataobj: Checks for duplicate segment data_object_id (My Oracle Support Note 1360519.1)
ObjSyn: Checks that a synonym has a valid entry in OBJ$ (My Oracle Support Note 1360520.1)
ObjSeq: Checks that a sequence has a valid entry in OBJ$ (My Oracle Support Note 1360524.1)
UndoSeg: Checks that undo segment has a valid entry in SEG$ (My Oracle Support Note 1360527.1)
IndexSeg: Checks that an index segment has a valid entry in SEG$ (My Oracle Support Note 1360531.1)
IndexPartitionSeg: Checks that an index partition has a valid entry in SEG$ (My Oracle Support Note 1360535.1)
IndexSubPartitionSeg: Checks that an index sub-partition has a valid entry in SEG$ (My Oracle Support Note 1360536.1)
TableSeg: Checks that a table has a valid entry in SEG$ (My Oracle Support Note 1360889.1)
TablePartitionSeg: Checks that a table partition has a valid entry in SEG$ (My Oracle Support Note 1360890.1)
TableSubPartitionSeg: Checks that a table sub-partition has a valid entry in SEG$ (My Oracle Support Note 1360891.1)
PartCol: Checks for valid entry of column partition (My Oracle Support Note 1360892.1)
ValidateSeg: Checks that a segment in SEG$ has an entry in its parent (My Oracle Support Note 1360934.1)
While running the ValidateSeg procedure, optionally, you can use the repair option to resolve inconsistencies. Valid values: TRUE|FALSE. Default: FALSE.
IndPartObj: Checks that an index partition has an entry in OBJ$ (My Oracle Support Note 1360935.1)
DuplicateBlockUse: Checks for a segment header block is used by only one segment (My Oracle Support Note 1360880.1)
FetUet: Checks valid free/used space in a dictionary-managed tablespace (My Oracle Support Note 1360882.1)
Uet0Check: Checks valid first extent in a dictionary-managed tablespace (My Oracle Support Note 1360883.1)
ExtentlessSeg: Checks SEG$/UET$ mismatch in a dictionary-managed tablespace (My Oracle Support Note 1360944.1)
SeglessUET: Checks UET$/SEG$ mismatch in a dictionary-managed tablespace (My Oracle Support Note 1360944.1)
ValidInd: Checks that an index in OBJ$ has a corresponding entry in the index dictionary (My Oracle Support Note 1360528.1)
ValidTab: Checks that a table in OBJ$ has a corresponding entry in TAB$ (My Oracle Support Note 1360538.1)
IcolDepCnt: Checks valid entries in ICOLDEP$ (My Oracle Support Note 1360938.1)
WarnIcolDep: Checks that an index does not have an ADT (object column) (My Oracle Support Note 1360939.1)
ObjIndDobj: Checks index data_object_id mismatch between OBJ$ and IND$ (My Oracle Support Note 1360968.1)
TrgAfterUpgrade: Checks valid entries in triggers (My Oracle Support Note 1361014.1)
ObjType0: Checks that OBJ$ has a valid type greater than 0 (My Oracle Support Note 1361015.1)
ValidOwner: Checks that an entry in OBJ$ has a valid user ID (My Oracle Support Note 1361020.1)
StmtAuditOnCommit: Checks valid entries for STMT_AUDIT_OPTION_MAP (My Oracle Support Note 1361021.1)
PublicObjects: Checks that objects are not owned by PUBLIC (My Oracle Support Note 1361022.1)
SegFreelist: Checks that a LOB segment has a valid free list group (My Oracle Support Note 1361023.1)
ValidDepends: Checks for valid dependency timestamps (My Oracle Support Note 1361045.1)
CheckDual: Checks valid entries in DUAL (My Oracle Support Note 1361046.1)
ObjectNames: Checks if an object has the same name as its schema owner (My Oracle Support Note 2363142.1)
CboHiLo: Checks for valid entries in histograms (My Oracle Support Note 1361047.1)
ChkIotTs: Checks that an IOT object does not have a segment (My Oracle Support Note 1361048.1)
NoSegmentIndex: Checks for NOSEGMENT indexes (My Oracle Support Note 1361049.1)
NextObject: Checks for valid data_object_id (My Oracle Support Note 2124772.1)
DroppedROTS: Checks for valid entries in a read-only tablespace (My Oracle Support Note 2124774.1)
FilBlkZero: Checks for zero data block address (My Oracle Support Note 2124783.1)
DbmsSchemaCopy: Checks for invalid execution of DBMS_SCHEMA_COPY (My Oracle Support Note 2124795.1)
IdnseqObj: Checks that Identity column has a valid object (My Oracle Support Note 2124805.1)
IdnseqSeq: Checks that a sequence has a valid object (My Oracle Support Note 2124787.1)
ObjError: Checks that an object error is valid (My Oracle Support Note 2124788.1)
ObjNotLob: Checks that a LOB object has an entry in LOB$ (My Oracle Support Note 2125104.1)
MaxControlfSeq: Checks if Control Seq is near the limit (My Oracle Support Note 2128446.1)
SegNotInDeferredStg: Checks for an invalid deferred segment (My Oracle Support Note 2298947.1)
SystemNotRfile1: Checks that the system tablespace has a relative file number 1 (My Oracle Support Note 2364065.1)
DictOwnNonDefaultSYSTEM: Checks that the users SYS and SYSTEM have default tablespace SYSTEM (My Oracle Support Note 2377270.1)
ValidateTrigger: Checks that triggers have valid entries in their parents (My Oracle Support Note 2384373.1)
ObjNotTrigger: Checks if an object trigger is not in TRIGGER$ (My Oracle Support Note 2384392.1)
WarningTSMaxSCN: Checks exposed SCN entries in tablespaces
InvalidTSMaxSCN: Checks for invalid SCN entries in tablespaces (My Oracle Support Note 1360208.1)
OBJRecycleBin: Checks that recycle bin objects in OBJ$ exist in RECYCLEBIN$ (My Oracle Support Note 2902943.1)
LobSeg: Checks that a LOB segment has a valid entry in SEG$ (My Oracle Support Note 2948392.1 and 2948408.1)
ObjLogicalConstraints: Checks logical constraints in OBJ$ (My Oracle Support Note 2977609.1 and Note 2977591.1)

Data Recovery Advisor
The Data Recovery Advisor integrates with database health checks and RMAN to display data corruption problems, assess the extent of each problem (critical, high priority, low priority), describe the impact of a problem, recommend repair options, conduct a feasibility check of the customer-chosen option, and automate the repair process.

Of course, there are many other tools and checks available for maintaining a robust database environment. Since each database is unique in its applications and infrastructure, DBAs should also implement custom checks tailored to their specific needs. There are many best practices you can follow, some of which are listed in the Customer Recommended Document titled ‘How to Perform a Health Check on the Database (Doc ID 122669.1)‘. These practices focus on areas such as the parameter file, control files, redo log files, archiving, datafile auto-extend attributes and locations, tablespace fragmentation and extent management, undo management, memory management, logging and tracing, among others.

Also, take a look at Carlos Sierra’s post, ‘A Healthy Way to Do an Oracle Database Health Check‘ , which shares valuable insights gained through years of experience, focusing more on the approach to be taken rather than purely technical details.

Hope it helps.


Discover More from Osman DİNÇ


Comments

One response to “Tools and Scripts for Oracle Database Health Checks and Diagnostics”

  1. Thank you very much for this post. Really helpful for me.

    Like

Leave your comment