The INSPECT 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 .
INSPECT is the generally available replacement for the deprecated EXPERIMENTAL SCRUB command.
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
INSPECT system-level , which is required to run the INSPECT statement.
Synopsis
Parameters
Options
Considerations
INSPECT always runs as a .
- By default,
INSPECT causes the SQL client to wait for the background job to complete and returns a NOTICE with the job ID. To return to the client as soon as the job is created (without waiting for it to finish), use the DETACHED option.
INSPECT can be run inside a if the DETACHED option is used. Otherwise, it needs to be run in an .
INSPECT runs with low priority under the subsystem and may take time on large datasets. Plan to run it during periods of lower system load.
- New in v26.2:
INSPECT runs secondary-index consistency checks on supported secondary indexes. On supported tables, it can also run uniqueness checks on the primary index to detect duplicate unique values across regions.
- The following index types are unsupported:
- Unsupported index types are automatically skipped when using the default
INDEX ALL behavior. If an unsupported index type is directly requested using INDEX {index_name}, the statement will fail before starting.
Examples
INSPECT a table (all supported checks)
INSPECT a table for specific indexes
Run a uniqueness check on a REGIONAL BY ROW primary index
New in v26.2: On supported tables, INSPECT will run uniqueness checks on the primary index to detect duplicate unique values across regions. This will also run any other checks supported by INSPECT:
INSPECT a table without waiting for completion
INSPECT at a specific timestamp
Checking INSPECT job status
When you issue the INSPECT statement, a NOTICE message is returned to the client showing the job ID:
You can check the status of the INSPECT using a statement like the following:
Viewing INSPECT results
To view errors found by an inspection job, use . Errors are stored in an internal system table and are subject to a 90 day retention policy.
See also