# DBMS_DICTIONARY_CHECK en Oracle 19.22: Un reemplazo para el Healthcheck tradicional

Con la versión 19.22 de Oracle Database, se ha incorporado de forma retroactiva el paquete DBMS\_DICTIONARY\_CHECK, proporcionando una forma más eficiente de validar la integridad del diccionario de datos.

Históricamente, esta tarea se realizaba mediante el script conocido como "**hcheck.sql**", que ejecutaba múltiples validaciones manuales sobre la estructura del diccionario.

En esta entrada, explicaré qué hace DBMS\_DICTIONARY\_CHECK, cómo se compara con los métodos anteriores y cuáles son sus beneficios.

**¿Qué es DBMS\_DICTIONARY\_CHECK?**

DBMS\_DICTIONARY\_CHECK es un paquete PL/SQL que permite verificar la consistencia del diccionario de datos de Oracle de una forma más automatizada y optimizada.

Su objetivo principal es detectar posibles corrupciones o inconsistencias en las estructuras internas de la base de datos antes de que se conviertan en problemas graves.

**Funcionalidades principales:**

Verifica la integridad de las estructuras clave del diccionario de datos.

Identifica objetos huérfanos o inconsistentes.

Reduce la necesidad de ejecutar múltiples scripts manuales para validaciones.

Ofrece un método más rápido y centralizado de chequeo.

**Comparación con el Healthcheck tradicional**

Antes de la introducción de DBMS\_DICTIONARY\_CHECK, los DBA solíamos ejecutar el script de verificación conocido como "**hcheck.sql**", los cuales:

Revisaba múltiples vistas del diccionario (DBA\_SEGMENTS, DBA\_OBJECTS, DBA\_TABLES, etc.).

Identificaba segmentos no válidos o estructuras inconsistentes.

Requería ejecución manual y análisis de resultados.

La diferencia clave con DBMS\_DICTIONARY\_CHECK es que este nuevo paquete encapsula todas estas validaciones dentro de **una ejecución más optimizada y directa**.

**Beneficios de DBMS\_DICTIONARY\_CHECK**

Automatización y facilidad de uso: Se puede ejecutar como un procedimiento almacenado.

Eficiencia mejorada: Optimiza las consultas internas para reducir el impacto en el rendimiento.

Menos margen de error: Reduce la posibilidad de omitir chequeos importantes.

Compatibilidad con versiones anteriores: Al haber sido incorporado en la versión 19.22, se puede usar en entornos que no han migrado aún a versiones más recientes.

Prevención temprana de problemas: Permite detectar inconsistencias antes de que generen errores críticos en la base de datos.

**Conclusión**

La incorporación de DBMS\_DICTIONARY\_CHECK en Oracle 19.22 representa un avance significativo en la administración de la integridad del diccionario de datos.

Su uso reemplaza de manera efectiva **hcheck** ofreciendo un enfoque más rápido y centralizado.

**Ejemplo ejecución:**

```plaintext
SYS@CDB$ROOT>  set serveroutput on size unlimited
SYS@CDB$ROOT>  execute dbms_dictionary_check.full
dbms_dictionary_check on 07-MAR-2025 15:11:23
----------------------------------------------
Catalog Version 19.0.0.0.0 (1900000000)
db_name: CDBXXX
Is CDB?: YES CON_ID: 1 Container: CDB$ROOT
Trace File: /u01/app/oracle/diag/rdbms/cdbxxx/cdbxxx1/trace/cdbxxxx1_ora_3844489_DICTCHECK.trc

                                   Catalog       Fixed
Procedure Name                     Version    Vs Release    Timestamp      Result
------------------------------ ... ---------- -- ---------- -------------- ------
.- OIDOnObjCol                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- LobNotInObj                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- SourceNotInObj              ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- OversizedFiles              ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- PoorDefaultStorage          ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- PoorStorage                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TabPartCountMismatch        ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TabComPartObj               ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- Mview                       ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidDir                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- DuplicateDataobj            ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjSyn                      ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjSeq                      ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- UndoSeg                     ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IndexSeg                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IndexPartitionSeg           ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IndexSubPartitionSeg        ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TableSeg                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TablePartitionSeg           ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TableSubPartitionSeg        ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- PartCol                     ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidSeg                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IndPartObj                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- DuplicateBlockUse           ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- FetUet                      ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- Uet0Check                   ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- SeglessUET                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidInd                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidTab                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IcolDepCnt                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjIndDobj                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- TrgAfterUpgrade             ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjType0                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidOwner                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- StmtAuditOnCommit           ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- PublicObjects               ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- SegFreelist                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidDepends                ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- CheckDual                   ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjectNames                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- CboHiLo                     ... 1900000000 <= 1902000000 03/07 15:11:23 PASS
.- ChkIotTs                    ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- NoSegmentIndex              ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- NextObject                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- DroppedROTS                 ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- FilBlkZero                  ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- DbmsSchemaCopy              ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- IdnseqObj                   ... 1900000000 >  1201000000 03/07 15:11:23 PASS
.- IdnseqSeq                   ... 1900000000 >  1201000000 03/07 15:11:23 PASS
.- ObjError                    ... 1900000000 >  1102000000 03/07 15:11:23 PASS
.- ObjNotLob                   ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- MaxControlfSeq              ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- SegNotInDeferredStg         ... 1900000000 >  1102000000 03/07 15:11:23 PASS
.- SystemNotRfile1             ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- DictOwnNonDefaultSYSTEM     ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ValidateTrigger             ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- ObjNotTrigger               ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- InvalidTSMaxSCN             ... 1900000000 >  1202000000 03/07 15:11:23 PASS
.- OBJRecycleBin               ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
.- LobSeg                      ... 1900000000 <=  *All Rel* 03/07 15:11:23 PASS
---------------------------------------
07-MAR-2025 15:11:23  Elapsed: 0 secs
---------------------------------------
Found 0 potential problem(s) and 0 warning(s)

Trace File: /u01/app/oracle/diag/rdbms/cdbxxx/cdbxxx1/trace/cdbxxx1_ora_3844489_DICTCHECK.trc

Procedimiento PL/SQL terminado correctamente.
```

Nos centramos en validaciones críticas:

```plaintext
SYS@CDB$ROOT>  execute dbms_dictionary_check.critical
dbms_dictionary_check on 07-MAR-2025 15:13:04
----------------------------------------------
Catalog Version 19.0.0.0.0 (1900000000)
db_name: CDBXXX
Is CDB?: YES CON_ID: 1 Container: CDB$ROOT
Trace File: /u01/app/oracle/diag/rdbms/cdbxxx/cdbxxx1/trace/cdbxxx1_ora_3844489_DICTCHECK.trc

                                   Catalog       Fixed
Procedure Name                     Version    Vs Release    Timestamp      Result
------------------------------ ... ---------- -- ---------- -------------- ------
.- UndoSeg                     ... 1900000000 <=  *All Rel* 03/07 15:13:04 PASS
.- MaxControlfSeq              ... 1900000000 <=  *All Rel* 03/07 15:13:04 PASS
.- InvalidTSMaxSCN             ... 1900000000 >  1202000000 03/07 15:13:04 PASS
---------------------------------------
07-MAR-2025 15:13:04  Elapsed: 0 secs
---------------------------------------
Found 0 potential problem(s) and 0 warning(s)

Trace File: /u01/app/oracle/diag/rdbms/cdbxxx/cdbxxx1/trace/cdbxxx1_ora_3844489_DICTCHECK.trc

Procedimiento PL/SQL terminado correctamente.
```

Te imaginas que se puede ejecutar con opción de reparación?

```plaintext
EXECUTE dbms_dictionary_check.ValidateSeg(repair=>TRUE)
```

Esto eliminaría los registros inconsistentes y restauraría la integridad del diccionario.
