Skip to main content
The SHOW RANGES statement shows information about the ranges that comprise the data for a table, index, database, or the current catalog. This information is useful for verifying how SQL data maps to underlying ranges, and where the replicas for those ranges are located. The statement syntax and output documented on this page use the updated SHOW RANGES that will become the default in CockroachDB v23.2. To enable this syntax and output, set the cluster setting sql.show_ranges_deprecated_behavior.enabled to false:
The pre-v23.1 output of SHOW RANGES is deprecated in v23.1 and will be removed in v23.2. When you use the deprecated version of the SHOW RANGES statement, the following message will appear, reminding you to update the cluster setting:
To show range information for a specific row in a table or index, use the SHOW RANGE ... FOR ROW statement.

Synopsis

show_ranges syntax diagram

Required privileges

To use the SHOW RANGES statement, a user must either be a member of the admin role (the root user belongs to the admin role by default) or have the ZONECONFIG privilege defined.

Parameters

Options

The following options are available to affect the output. Multiple options can be passed at once, separated by commas.

Response

The specific fields in the response vary depending on the values passed as options. The following fields may be returned:

Examples

The statement syntax and output documented on this page use the updated SHOW RANGES that will become the default in CockroachDB v23.2. To enable this syntax and output, set the cluster setting sql.show_ranges_deprecated_behavior.enabled to false:
The pre-v23.1 output of SHOW RANGES is deprecated in v23.1 and will be removed in v23.2. When you use the deprecated version of the SHOW RANGES statement, the following message will appear, reminding you to update the cluster setting:

Setup

The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see MovR: A Global Vehicle-sharing App. To follow along, run cockroach demo with the --geo-partitioned-replicas flag. This command opens an interactive SQL shell to a temporary, 9-node in-memory cluster with the movr database.

Show ranges for a database

Show ranges for a database (without options)

Show ranges for a database (with tables, keys, details)

Show ranges for a database (with tables)

Show ranges for a database (with indexes)

Show ranges for a database (with details)

Show ranges for a database (with keys)

Show ranges for a table

Show ranges for a table (without options)

Show ranges for a table (with indexes, keys, details)

Show ranges for a table (with indexes)

Show ranges for a table (with details)

Show ranges for a table (with keys)

Show ranges for an index

Show ranges for an index (without options)

Show ranges for an index (with keys, details)

Show ranges for an index (with details)

Show ranges for an index (with keys)

See also