> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# VERIFY DATABASE

Verifies that the database is in a consistent state across the cluster.  The
verification compares the metadata on the head node with the metadata on each
worker, and checks that each table's records are counted and distributed
consistently across the ranks.  Options add checks of null values and of
persisted objects, and can limit the table checks to particular tables.  Only
users with the `system_admin`
[permission](https://docs.kinetica.com/content/security/sec_concepts.md#security-concepts-permissions) can issue this
command, and it cannot be run while the database is in read-only mode.

To check individual tables for corrupted data, see
[CHECK TABLE](https://docs.kinetica.com/content/sql/ddl/check-table.md#sql-check-table); to repair them, see
[REPAIR TABLE](https://docs.kinetica.com/content/sql/ddl/repair-table.md#sql-repair-table).

```sql title="VERIFY DATABASE Syntax" theme={null}
VERIFY DATABASE
[WITH OPTIONS ('<option name>' = '<option value>'[,...])]
```

> [!NOTE]
>
> Through SQL, the verification runs as part of the SQL statement, alongside
> any other database activity, rather than on its own.  As a result:
>
> * Orphaned table data (table data on the workers with no corresponding
>   metadata) is not checked.  To check for orphaned table data, use the
>   [/admin/verifydb](https://docs.kinetica.com/content/api/rest/admin_verifydb_rest.md) endpoint, which pauses other
>   database activity while it runs.
> * Differences in metadata between the head node and the workers may be
>   reported while other DDL is in progress.  Run the verification again to
>   confirm any such finding before acting on it.

## Options

The following options can be specified in the `WITH OPTIONS` clause.  Both the
option names and their values must be quoted.

> **verify\_nulls**
>
> When `true`, verifies that null values are set to zero.  The default is `false`.

> **verify\_persist**
>
> When `true`, compares persistent objects against their state in memory.  The default
> is `false`.

> **verify\_rank0**
>
> When `true`, compares the table metadata on the head node (rank 0) against the table
> metadata on each worker.  The default is `false`.

> **table\_includes**
>
> Comma-separated list of tables to include when verifying table consistency on the
> workers; all other tables are skipped.  Cannot be used with `table_excludes`.

> **table\_excludes**
>
> Comma-separated list of tables to exclude when verifying table consistency on the
> workers.  Cannot be used with `table_includes`.

## Response

The response to `VERIFY DATABASE` is a single-row, 3-column result set:

| Output Column | Description |
| - | - |
| `VERIFIED_OK` | Whether the verification found the database to be in a consistent state. |
| `ERROR_LIST` | List of the inconsistencies found.   This list can contain findings even when `VERIFIED_OK` is `true`, so review it rather than relying on `VERIFIED_OK` alone. |
| `ORPHANED_TABLES_TOTAL_SIZE` | Total size, in bytes, of the orphaned table data found; `-1` when orphaned table data was not checked, as is the case when verifying through SQL. |

## Examples

To verify the database:

```sql VERIFY DATABASE Example theme={null}
VERIFY DATABASE
```

To verify the database, also checking null values and comparing the table
metadata on the head node against that on the workers:

```sql VERIFY DATABASE with Options Example theme={null}
VERIFY DATABASE
WITH OPTIONS ('verify_nulls' = 'true', 'verify_rank0' = 'true')
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.