Skip to main content
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

inspect_table syntax diagram inspect_database syntax diagram

Parameters

ParameterDescription
table_nameThe to inspect.
db_nameThe to inspect.
opt_as_of_clauseOptional. 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 .
opt_inspect_options_clauseOptional. Control which are used to plan INSPECT checks with INSPECT ... WITH OPTIONS (...). For an example, see INSPECT a table for specific indexes. See Options.

Options

OptionDescription
INDEX ALLRun all supported INSPECT checks for the target table or database. This is the default.
INDEX ({index_name} [, ...])Run checks only for the specified indexes. New in v26.2: On supported tables, naming the primary index can also trigger a uniqueness check. Note that INDEX ALL and this option are mutually exclusive.
DETACHEDRun 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 .

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