The INSPECT statement runs a data consistency validation job against a table or database and records any errors it finds. To display errors recorded by an inspection job, use SHOW INSPECT ERRORS.
INSPECT is used to verify data integrity. It does not automatically repair errors.
Required privileges
To run INSPECT and view its results, the user must have:
- The
INSPECTsystem-level privilege is required to run theINSPECTstatement. - The
VIEWSYSTEMTABLEsystem-level privilege, which is required to view the results ofSHOW INSPECT ERRORS.
Synopsis
Parameters
| Parameter | Description |
|---|---|
table_name |
The table to inspect. |
db_name |
The database to inspect. |
opt_as_of_clause |
Optional. Run the inspection against a historical read timestamp using INSPECT ... AS OF SYSTEM TIME {expr}. For an example, see INSPECT at a specific timestamp. For more information about historical reads, see AS OF SYSTEM TIME. |
opt_inspect_options_clause |
Optional. Control which indexes are inspected using INSPECT ... WITH OPTIONS (...). For an example, see INSPECT a table for specific indexes. See Options. |
Options
| Option | Description |
|---|---|
INDEX ALL |
Inspect all supported index types in the target table or database. This is the default. |
INDEX ({index_name} [, ...]) |
Inspect only the specified indexes. Note that INDEX ALL and this option are mutually exclusive. |
DETACHED |
Run INSPECT in detached mode so the statement returns to the SQL client after the job is created (instead of waiting for the job to complete). For an example, see INSPECT a table without waiting for completion. This option allows INSPECT to run inside a multi-statement transaction. |
Considerations
INSPECTalways runs as a background job.- By default,
INSPECTcauses the SQL client to wait for the background job to complete and returns aNOTICEwith the job ID. To return to the client as soon as the job is created (without waiting for it to finish), use theDETACHEDoption. INSPECTcan be run inside a multi-statement transaction if theDETACHEDoption is used. Otherwise, it needs to be run in an implicit transaction.INSPECTruns with low priority under the admission control subsystem and may take time on large datasets. Plan to run it during periods of lower system load.- The following index types are unsupported:
- Unsupported index types are automatically skipped when using the default
INDEX ALLbehavior. If an unsupported index type is directly requested usingINDEX {index_name}, the statement will fail before starting.
Examples
INSPECT a table (all supported indexes)
INSPECT TABLE movr.public.users;
NOTICE: waiting for INSPECT job to complete: 1141477630617223169
If the statement is canceled, the job will continue in the background.
INSPECT a table for specific indexes
INSPECT TABLE movr.public.vehicles WITH OPTIONS INDEX (vehicles_auto_index_fk_city_ref_users);
NOTICE: waiting for INSPECT job to complete: 1141477560713150465
If the statement is canceled, the job will continue in the background.
INSPECT a table without waiting for completion
INSPECT TABLE movr.public.vehicles WITH OPTIONS DETACHED;
NOTICE: INSPECT job 1141773037670301697 running in the background
INSPECT at a specific timestamp
INSPECT TABLE movr.public.users AS OF SYSTEM TIME '-10s';
NOTICE: waiting for INSPECT job to complete: 1141477013029322753
If the statement is canceled, the job will continue in the background.
Checking INSPECT job status
When you issue the INSPECT statement, a NOTICE message is returned to the client showing the job ID:
NOTICE: waiting for INSPECT job to complete: 1141477013029322753
If the statement is canceled, the job will continue in the background.
You can check the status of the INSPECT job using a statement like the following:
SELECT * FROM [SHOW JOBS] WHERE job_id = 1141477013029322753;
job_id | job_type | description | user_name | status | running_status | created | started | finished | modified | fraction_completed | error | coordinator_id
----------------------+----------+---------------------------------+-----------+-----------+----------------+------------------------+------------------------+------------------------+------------------------+--------------------+-------+-----------------
1141477013029322753 | INSPECT | INSPECT TABLE movr.public.users | node | succeeded | NULL | 2026-01-14 20:12:19+00 | 2026-01-14 20:12:19+00 | 2026-01-14 20:12:19+00 | 2026-01-14 20:12:19+00 | 1 | | 1
Viewing INSPECT results
To view errors found by an inspection job, use SHOW INSPECT ERRORS. Errors are stored in an internal system table and are subject to a 90 day retention policy.