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

# SHOW RANGES

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `SHOW RANGES` <InternalLink path="sql-statements">statement</InternalLink> shows information about the <InternalLink path="architecture/overview">ranges</InternalLink> 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 <InternalLink path="architecture/overview">ranges</InternalLink>, and where the <InternalLink path="architecture/glossary#replica">replicas</InternalLink> 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 <InternalLink path="cluster-settings">cluster setting `sql.show_ranges_deprecated_behavior.enabled`</InternalLink>  to `false`:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SET CLUSTER SETTING sql.show_ranges_deprecated_behavior.enabled = 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 <InternalLink path="cluster-settings">the cluster setting</InternalLink>:

```
NOTICE: attention! the pre-23.1 behavior of SHOW RANGES and crdb_internal.ranges{,_no_leases} is deprecated!
HINT: Consider enabling the new functionality by setting 'sql.show_ranges_deprecated_behavior.enabled' to 'false'.
The new SHOW RANGES statement has more options. Refer to the online documentation or execute 'SHOW RANGES ??' for details.
```

<Tip>
  To show range information for a specific row in a table or index, use the <InternalLink path="show-range-for-row">`SHOW RANGE ... FOR ROW`</InternalLink> statement.
</Tip>

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/hRoSoqt0mqHbZVjm/images/sql-diagrams/v23.1/show_ranges.svg?fit=max&auto=format&n=hRoSoqt0mqHbZVjm&q=85&s=6378b844e87e474c3f54d2b718ebc192" alt="show_ranges syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="669" height="311" data-path="images/sql-diagrams/v23.1/show_ranges.svg" />

## Required privileges

To use the `SHOW RANGES` statement, a user must either be a member of the <InternalLink path="security-reference/authorization#admin-role">`admin`</InternalLink> role (the `root` user belongs to the `admin` role by default) or have the `ZONECONFIG` <InternalLink path="security-reference/authorization#managing-privileges">privilege</InternalLink> defined.

## Parameters

| Parameter                                                                 | Description                                                                                                                                                             |
| ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <InternalLink path="sql-grammar">`table_name`</InternalLink>              | The name of the <InternalLink path="show-tables">table</InternalLink> you want <InternalLink path="architecture/overview">range</InternalLink> information about.       |
| <InternalLink path="sql-grammar">`table_index_name`</InternalLink>        | The name of the <InternalLink path="indexes">index</InternalLink> you want <InternalLink path="architecture/overview">range</InternalLink> information about.           |
| <InternalLink path="sql-grammar">`database_name`</InternalLink>           | The name of the <InternalLink path="show-databases">database</InternalLink> you want <InternalLink path="architecture/overview">range</InternalLink> information about. |
| <InternalLink path="sql-grammar">`opt_show_ranges_options`</InternalLink> | The [options](#options) used to configure what fields appear in the [response](#response).                                                                              |

## Options

The following <InternalLink path="sql-grammar">options</InternalLink> are available to affect the output. Multiple options can be passed at once, separated by commas.

* `TABLES`:  List <InternalLink path="show-tables">tables</InternalLink> contained per <InternalLink path="architecture/overview">range</InternalLink>.
* `INDEXES`: List <InternalLink path="indexes">indexes</InternalLink> contained per <InternalLink path="architecture/overview">range</InternalLink>.
* `DETAILS`: Add <InternalLink path="architecture/overview">range</InternalLink> size, <InternalLink path="architecture/glossary#leaseholder">leaseholder</InternalLink> and other details. Note that this incurs a large computational overhead because it needs to fetch data across nodes.
* `KEYS`:    Include binary [start and end keys](#start-key).

## Response

The specific fields in the response vary depending on the values passed as [options](#options). The following fields may be returned:

| Field                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                             | Emitted for option(s) |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `start_key`             | The start key for the <InternalLink path="architecture/overview">range</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                  | Always emitted.       |
| `end_key`               | The end key for the <InternalLink path="architecture/overview">range</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                    | Always emitted.       |
| `raw_start_key`         | The start key for the <InternalLink path="architecture/overview">range</InternalLink>, displayed as a <InternalLink path="sql-constants#string-literals-with-character-escapes">hexadecimal byte value</InternalLink>.                                                                                                                                                                                                                                  | `KEYS`                |
| `raw_end_key`           | The end key for the <InternalLink path="architecture/overview">range</InternalLink>, displayed as a <InternalLink path="sql-constants#string-literals-with-character-escapes">hexadecimal byte value</InternalLink>.                                                                                                                                                                                                                                    | `KEYS`                |
| `range_id`              | The internal <InternalLink path="architecture/overview">range</InternalLink> ID.                                                                                                                                                                                                                                                                                                                                                                        | Always emitted.       |
| `voting_replicas`       | The <InternalLink path="architecture/glossary#node">nodes</InternalLink> that contain the range's voting replicas (that is, the replicas that participate in <InternalLink path="architecture/replication-layer#raft">Raft</InternalLink> elections).                                                                                                                                                                                                   | Always emitted.       |
| `non_voting_replicas`   | The <InternalLink path="architecture/glossary#node">nodes</InternalLink> that contain the range's <InternalLink path="architecture/replication-layer#non-voting-replicas">non-voting replicas</InternalLink>.                                                                                                                                                                                                                                           | Always emitted.       |
| `replicas`              | The <InternalLink path="architecture/glossary#node">nodes</InternalLink> that contain the range's <InternalLink path="architecture/glossary#replica">replicas</InternalLink>.                                                                                                                                                                                                                                                                           | Always emitted.       |
| `replica_localities`    | The <InternalLink path="cockroach-start#locality">localities</InternalLink> of the range's <InternalLink path="architecture/glossary#replica">replicas</InternalLink>.                                                                                                                                                                                                                                                                                  | Always emitted.       |
| `range_size`            | The size of the <InternalLink path="architecture/overview">range</InternalLink> in bytes.                                                                                                                                                                                                                                                                                                                                                               | `DETAILS`             |
| `range_size_mb`         | The size of the <InternalLink path="architecture/overview">range</InternalLink> in MiB.                                                                                                                                                                                                                                                                                                                                                                 | `DETAILS`             |
| `lease_holder`          | The  <InternalLink path="architecture/glossary#node">node</InternalLink> that contains the range's <InternalLink path="architecture/glossary#leaseholder">leaseholder</InternalLink>.                                                                                                                                                                                                                                                                   | `DETAILS`             |
| `lease_holder_locality` | The <InternalLink path="cockroach-start#locality">locality</InternalLink> of the range's <InternalLink path="architecture/glossary#leaseholder">leaseholder</InternalLink>.                                                                                                                                                                                                                                                                             | `DETAILS`             |
| `learner_replicas`      | The *learner replicas* of the range. A learner replica is a replica that has just been added to a range, and is thus in an interim state. It accepts messages but doesn't vote in <InternalLink path="architecture/replication-layer#raft">Raft</InternalLink> elections. This means it doesn't affect quorum and thus doesn't affect the stability of the range, even if it's very far behind.                                                         | Always emitted.       |
| `split_enforced_until`  | The time a <InternalLink path="architecture/distribution-layer#range-splits">range split</InternalLink> is enforced until. This can be set using <InternalLink path="alter-table#split-at">`ALTER TABLE ... SPLIT AT`</InternalLink> using the <InternalLink path="alter-table#set-the-expiration-on-a-split-enforcement">`WITH EXPIRATION` clause</InternalLink>. Example: `2262-04-11 23:47:16.854776` (this is a default value which means "never"). | Always emitted.       |
| `schema_name`           | The name of the <InternalLink path="create-schema">schema</InternalLink> this <InternalLink path="architecture/overview">range</InternalLink> holds data for.                                                                                                                                                                                                                                                                                           | `TABLES`, `INDEXES`   |
| `table_name`            | The name of the <InternalLink path="create-table">table</InternalLink> this <InternalLink path="architecture/overview">range</InternalLink> holds data for.                                                                                                                                                                                                                                                                                             | `TABLES`, `INDEXES`   |
| `table_id`              | The internal ID of the <InternalLink path="create-table">table</InternalLink> this <InternalLink path="architecture/overview">range</InternalLink> holds data for.                                                                                                                                                                                                                                                                                      | `TABLES`, `INDEXES`   |
| `table_start_key`       | The start key of the first <InternalLink path="architecture/overview">range</InternalLink> that holds data for this table.                                                                                                                                                                                                                                                                                                                              | `TABLES`              |
| `table_end_key`         | The end key of the last <InternalLink path="architecture/overview">range</InternalLink> that holds data for this table.                                                                                                                                                                                                                                                                                                                                 | `TABLES`              |
| `raw_table_start_key`   | The start key of the first <InternalLink path="architecture/overview">range</InternalLink> that holds data for this table, expressed as <InternalLink path="bytes">`BYTES`</InternalLink>.                                                                                                                                                                                                                                                              | `TABLES`, `KEYS`      |
| `raw_table_end_key`     | The end key of the last <InternalLink path="architecture/overview">range</InternalLink> that holds data for this table, expressed as <InternalLink path="bytes">`BYTES`</InternalLink>.                                                                                                                                                                                                                                                                 | `TABLES`, `KEYS`      |
| `index_name`            | The name of the <InternalLink path="indexes">index</InternalLink> this <InternalLink path="architecture/overview">range</InternalLink> holds data for.                                                                                                                                                                                                                                                                                                  | `INDEXES`             |
| `index_id`              | The internal ID of the <InternalLink path="indexes">index</InternalLink> this <InternalLink path="architecture/overview">range</InternalLink> holds data for.                                                                                                                                                                                                                                                                                           | `INDEXES`             |
| `index_start_key`       | The start key of the first <InternalLink path="architecture/overview">range</InternalLink> of <InternalLink path="indexes">index</InternalLink> data.                                                                                                                                                                                                                                                                                                   | `INDEXES`             |
| `index_end_key`         | The end key of the last <InternalLink path="architecture/overview">range</InternalLink> of <InternalLink path="indexes">index</InternalLink> data.                                                                                                                                                                                                                                                                                                      | `INDEXES`             |
| `raw_index_start_key`   | The start key of the first <InternalLink path="architecture/overview">range</InternalLink> of <InternalLink path="indexes">index</InternalLink> data, expressed as <InternalLink path="bytes">`BYTES`</InternalLink>.                                                                                                                                                                                                                                   | `INDEXES`, `KEYS`     |
| `raw_index_end_key`     | The end key of the last <InternalLink path="architecture/overview">range</InternalLink> of <InternalLink path="indexes">index</InternalLink> data, expressed as <InternalLink path="bytes">`BYTES`</InternalLink>.                                                                                                                                                                                                                                      | `INDEXES`, `KEYS`     |

## 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 <InternalLink path="cluster-settings">cluster setting `sql.show_ranges_deprecated_behavior.enabled`</InternalLink>  to `false`:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SET CLUSTER SETTING sql.show_ranges_deprecated_behavior.enabled = 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 <InternalLink path="cluster-settings">the cluster setting</InternalLink>:

```
NOTICE: attention! the pre-23.1 behavior of SHOW RANGES and crdb_internal.ranges{,_no_leases} is deprecated!
HINT: Consider enabling the new functionality by setting 'sql.show_ranges_deprecated_behavior.enabled' to 'false'.
The new SHOW RANGES statement has more options. Refer to the online documentation or execute 'SHOW RANGES ??' for details.
```

#### 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 <InternalLink path="movr">MovR: A Global Vehicle-sharing App</InternalLink>.

To follow along, run <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink> 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.

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach demo --geo-partitioned-replicas
```

### Show ranges for a database

* [Show ranges for a database (without options)](#show-ranges-for-a-database-without-options)
* [Show ranges for a database (with tables, keys, details)](#show-ranges-for-a-database-with-tables-keys-details)
* [Show ranges for a database (with tables)](#show-ranges-for-a-database-with-tables)
* [Show ranges for a database (with indexes)](#show-ranges-for-a-database-with-indexes)
* [Show ranges for a database (with details)](#show-ranges-for-a-database-with-details)
* [Show ranges for a database (with keys)](#show-ranges-for-a-database-with-keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW DATABASES;
```

```
  database_name | owner | primary_region | secondary_region | regions | survival_goal
----------------+-------+----------------+------------------+---------+----------------
  defaultdb     | root  | NULL           | NULL             | {}      | NULL
  movr          | demo  | NULL           | NULL             | {}      | NULL
  postgres      | root  | NULL           | NULL             | {}      | NULL
  system        | node  | NULL           | NULL             | {}      | NULL
(4 rows)
```

#### Show ranges for a database (without options)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr;
```

```
                                           start_key                                           |                                           end_key                                            | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         |      309 | {3,5,9}  | {"region=us-east1,az=d","region=us-west1,az=b","region=europe-west1,az=d"}         | {3,5,9}         | {}                  | {}               | NULL
(178 rows)
```

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

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr WITH TABLES, KEYS, DETAILS;
```

```
                                           start_key                                           |                                           end_key                                            |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id | schema_name |         table_name         | table_id | table_start_key |    table_end_key     | raw_table_start_key | raw_table_end_key |       range_size_mb        | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+-------------+----------------------------+----------+-----------------+----------------------+---------------------+-------------------+----------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |      174 | public      | users                      |      106 | /Table/106      | /Table/107           | \xf2                | \xf3              |                          0 |            3 | region=us-east1,az=d     | {3,6,9}  | {"region=us-east1,az=d","region=us-west1,az=c","region=europe-west1,az=d"}         | {3,9,6}         | {}                  | {}               | NULL                       |          0
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |      175 | public      | users                      |      106 | /Table/106      | /Table/107           | \xf2                | \xf3              |  0.00011900000000000000000 |            3 | region=us-east1,az=d     | {3,7,8}  | {"region=us-east1,az=d","region=europe-west1,az=b","region=europe-west1,az=c"}     | {3,7,8}         | {}                  | {}               | NULL                       |        119
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         | \xf66f891277617368696e67746f6e2064630002                                                             | \xffff                                                                                               |      295 | public      | user_promo_codes           |      111 | /Table/111      | /Table/112           | \xf66f              | \xf670            |                          0 |            8 | region=europe-west1,az=c | {3,4,8}  | {"region=us-east1,az=d","region=us-west1,az=a","region=europe-west1,az=c"}         | {3,8,4}         | {}                  | {}               | NULL                       |          0
(145 rows)
```

#### Show ranges for a database (with tables)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr WITH TABLES;
```

```
                                           start_key                                           |                                           end_key                                            | range_id | schema_name |         table_name         | table_id | table_start_key |    table_end_key     | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------+-------------+----------------------------+----------+-----------------+----------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     |       67 | public      | users                      |      106 | /Table/106      | /Table/107           | {1,4,9}  | {"region=us-east1,az=b","region=us-west1,az=a","region=europe-west1,az=d"}         | {1,9,4}         | {}                  | {}               | NULL
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       68 | public      | users                      |      106 | /Table/106      | /Table/107           | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {7,9,8}         | {}                  | {}               | NULL
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         |      311 | public      | user_promo_codes           |      111 | /Table/111      | /Table/112           | {1,5,7}  | {"region=us-east1,az=b","region=us-west1,az=b","region=europe-west1,az=b"}         | {1,7,5}         | {}                  | {}               | NULL
(178 rows)
```

#### Show ranges for a database (with indexes)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr WITH INDEXES;
```

```
                                           start_key                                           |                                           end_key                                            | range_id | schema_name |         table_name         | table_id |                  index_name                   | index_id | index_start_key | index_end_key | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------+-------------+----------------------------+----------+-----------------------------------------------+----------+-----------------+---------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     |       70 | public      | users                      |      106 | users_pkey                                    |        1 | /Table/106/1    | /Table/106/2  | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 | public      | users                      |      106 | users_pkey                                    |        1 | /Table/106/1    | /Table/106/2  | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         |      309 | public      | user_promo_codes           |      111 | user_promo_codes_pkey                         |        1 | /Table/111/1    | /Table/111/2  | {3,5,9}  | {"region=us-east1,az=d","region=us-west1,az=b","region=europe-west1,az=d"}         | {3,5,9}         | {}                  | {}               | NULL
(179 rows)
```

#### Show ranges for a database (with details)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr WITH DETAILS;
```

```
                                           start_key                                           |                                           end_key                                            | range_id |       range_size_mb        | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+----------+----------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     |       70 |                          0 |            1 | region=us-east1,az=b     | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL                       |          0
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 |  0.00011800000000000000000 |            9 | region=europe-west1,az=d | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL                       |        118
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         |      309 |                          0 |            9 | region=europe-west1,az=d | {3,5,9}  | {"region=us-east1,az=d","region=us-west1,az=b","region=europe-west1,az=d"}         | {3,5,9}         | {}                  | {}               | NULL                       |          0
(178 rows)
```

#### Show ranges for a database (with keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM DATABASE movr WITH KEYS;
```

```
                                           start_key                                           |                                           end_key                                            |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
-----------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  /Table/106                                                                                   | /Table/106/1/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  /Table/106/1/"amsterdam"                                                                     | /Table/106/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  /Table/111/1/"washington dc"/PrefixEnd                                                       | /Max                                                                                         | \xf66f891277617368696e67746f6e2064630002                                                             | \xffff                                                                                               |      309 | {3,5,9}  | {"region=us-east1,az=d","region=us-west1,az=b","region=europe-west1,az=d"}         | {3,5,9}         | {}                  | {}               | NULL
(178 rows)
```

### Show ranges for a table

* [Show ranges for a table (without options)](#show-ranges-for-a-table-without-options)
* [Show ranges for a table (with indexes, keys, details)](#show-ranges-for-a-table-with-indexes-keys-details)
* [Show ranges for a table (with indexes)](#show-ranges-for-a-table-with-indexes)
* [Show ranges for a table (with details)](#show-ranges-for-a-table-with-details)
* [Show ranges for a table (with keys)](#show-ranges-for-a-table-with-keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW TABLES;
```

```
  schema_name |         table_name         | type  | owner | estimated_row_count | locality
--------------+----------------------------+-------+-------+---------------------+-----------
  public      | promo_codes                | table | demo  |                1000 | NULL
  public      | rides                      | table | demo  |                 500 | NULL
  public      | user_promo_codes           | table | demo  |                   5 | NULL
  public      | users                      | table | demo  |                  50 | NULL
  public      | vehicle_location_histories | table | demo  |                1000 | NULL
  public      | vehicles                   | table | demo  |                  15 | NULL
(6 rows)
```

#### Show ranges for a table (without options)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM TABLE movr.users;
```

```
                                       start_key                                      |                                       end_key                                       | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
--------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  …/<TableMin>                                                                        | …/1/"amsterdam"                                                                     |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  …/1/"amsterdam"                                                                     | …/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  …/1/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                        |      154 | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL
(27 rows)
```

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

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM TABLE movr.users with INDEXES, KEYS, DETAILS;
```

```
                                       start_key                                      |                                       end_key                                       |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id | index_name | index_id | index_start_key | index_end_key | raw_index_start_key | raw_index_end_key |       range_size_mb       | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
--------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+------------+----------+-----------------+---------------+---------------------+-------------------+---------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  …/<TableMin>                                                                        | …/1/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |      174 | users_pkey |        1 | …/1             | …/2           | \xf289              | \xf28a            |                         0 |            3 | region=us-east1,az=d     | {3,6,9}  | {"region=us-east1,az=d","region=us-west1,az=c","region=europe-west1,az=d"}         | {3,9,6}         | {}                  | {}               | NULL                       |          0
  …/1/"amsterdam"                                                                     | …/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |      175 | users_pkey |        1 | …/1             | …/2           | \xf289              | \xf28a            | 0.00011900000000000000000 |            9 | region=europe-west1,az=d | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL                       |        119
  ...
  …/1/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                        | \xf2891277617368696e67746f6e2064630002                                                               | \xf3                                                                                                 |      111 | users_pkey |        1 | …/1             | …/2           | \xf289              | \xf28a            |                         0 |            9 | region=europe-west1,az=d | {1,5,9}  | {"region=us-east1,az=b","region=us-west1,az=b","region=europe-west1,az=d"}         | {1,9,5}         | {}                  | {}               | NULL                       |          0
(27 rows)
```

#### Show ranges for a table (with indexes)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM TABLE movr.users WITH INDEXES;
```

```
                                       start_key                                      |                                       end_key                                       | range_id | index_name | index_id | index_start_key | index_end_key | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
--------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+----------+------------+----------+-----------------+---------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  …/<TableMin>                                                                        | …/1/"amsterdam"                                                                     |       70 | users_pkey |        1 | …/1             | …/2           | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  …/1/"amsterdam"                                                                     | …/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 | users_pkey |        1 | …/1             | …/2           | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  …/1/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                        |      154 | users_pkey |        1 | …/1             | …/2           | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL
(27 rows)
```

#### Show ranges for a table (with details)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM TABLE movr.users WITH DETAILS;
```

```
                                       start_key                                      |                                       end_key                                       | range_id |       range_size_mb        | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
--------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+----------+----------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  …/<TableMin>                                                                        | …/1/"amsterdam"                                                                     |       70 |                          0 |            1 | region=us-east1,az=b     | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL                       |          0
  …/1/"amsterdam"                                                                     | …/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 |  0.00011800000000000000000 |            9 | region=europe-west1,az=d | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL                       |        118
  ...
  …/1/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                        |      154 |                          0 |            4 | region=us-west1,az=a     | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL                       |          0
(27 rows)
```

#### Show ranges for a table (with keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM TABLE movr.users WITH KEYS;
```

```
                                       start_key                                      |                                       end_key                                       |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
--------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  …/<TableMin>                                                                        | …/1/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  …/1/"amsterdam"                                                                     | …/1/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  …/1/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                        | \xf2891277617368696e67746f6e2064630002                                                               | \xf3                                                                                                 |      154 | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL
(27 rows)
```

### Show ranges for an index

* [Show ranges for an index (without options)](#show-ranges-for-an-index-without-options)
* [Show ranges for an index (with keys, details)](#show-ranges-for-an-index-with-keys-details)
* [Show ranges for an index (with details)](#show-ranges-for-an-index-with-details)
* [Show ranges for an index (with keys)](#show-ranges-for-an-index-with-keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW INDEXES FROM movr.users;
```

```
  table_name | index_name | non_unique | seq_in_index | column_name | definition  | direction | storing | implicit | visible
-------------+------------+------------+--------------+-------------+-------------+-----------+---------+----------+----------
  users      | users_pkey |     f      |            1 | city        | city        | ASC       |    f    |    f     |    t
  users      | users_pkey |     f      |            2 | id          | id          | ASC       |    f    |    f     |    t
  users      | users_pkey |     f      |            3 | name        | name        | N/A       |    t    |    f     |    t
  users      | users_pkey |     f      |            4 | address     | address     | N/A       |    t    |    f     |    t
  users      | users_pkey |     f      |            5 | credit_card | credit_card | N/A       |    t    |    f     |    t
(5 rows)
```

#### Show ranges for an index (without options)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM INDEX movr.users_pkey;
```

```
                                      start_key                                     |                                      end_key                                      | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  …/TableMin                                                                        | …/"amsterdam"                                                                     |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  …/"amsterdam"                                                                     | …/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  …/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                      |      154 | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL
(27 rows)
```

#### Show ranges for an index (with keys, details)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM INDEX movr.users_pkey WITH KEYS, DETAILS;
```

```
                                      start_key                                     |                                      end_key                                      |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id |       range_size_mb       | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+---------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  …/TableMin                                                                        | …/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |      174 |                         0 |            3 | region=us-east1,az=d     | {3,6,9}  | {"region=us-east1,az=d","region=us-west1,az=c","region=europe-west1,az=d"}         | {3,9,6}         | {}                  | {}               | NULL                       |          0
  …/"amsterdam"                                                                     | …/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |      175 | 0.00011900000000000000000 |            9 | region=europe-west1,az=d | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL                       |        119
  ...
  …/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                      | \xf2891277617368696e67746f6e2064630002                                                               | \xf3                                                                                                 |      111 |                         0 |            9 | region=europe-west1,az=d | {1,5,9}  | {"region=us-east1,az=b","region=us-west1,az=b","region=europe-west1,az=d"}         | {1,9,5}         | {}                  | {}               | NULL                       |          0
(27 rows)
```

#### Show ranges for an index (with details)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM INDEX movr.users_pkey WITH DETAILS;
```

```
                                      start_key                                     |                                      end_key                                      | range_id |       range_size_mb        | lease_holder |  lease_holder_locality   | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until    | range_size
------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+----------+----------------------------+--------------+--------------------------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+----------------------------+-------------
  …/TableMin                                                                        | …/"amsterdam"                                                                     |       70 |                          0 |            1 | region=us-east1,az=b     | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL                       |          0
  …/"amsterdam"                                                                     | …/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       |       71 |  0.00011800000000000000000 |            9 | region=europe-west1,az=d | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL                       |        118
  ...
  …/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                      |      154 |                          0 |            4 | region=us-west1,az=a     | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL                       |          0
(27 rows)
```

#### Show ranges for an index (with keys)

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW RANGES FROM INDEX movr.users_pkey WITH KEYS;
```

```
                                      start_key                                     |                                      end_key                                      |                                            raw_start_key                                             |                                             raw_end_key                                              | range_id | replicas |                                 replica_localities                                 | voting_replicas | non_voting_replicas | learner_replicas |    split_enforced_until
------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+----------+----------+------------------------------------------------------------------------------------+-----------------+---------------------+------------------+-----------------------------
  …/TableMin                                                                        | …/"amsterdam"                                                                     | \xf2                                                                                                 | \xf28912616d7374657264616d0001                                                                       |       70 | {1,6,8}  | {"region=us-east1,az=b","region=us-west1,az=c","region=europe-west1,az=c"}         | {1,6,8}         | {}                  | {}               | NULL
  …/"amsterdam"                                                                     | …/"amsterdam"/"\xb333333@\x00\x80\x00\x00\x00\x00\x00\x00#"                       | \xf28912616d7374657264616d0001                                                                       | \xf28912616d7374657264616d000112b333333333334000ff8000ff00ff00ff00ff00ff00ff230001                   |       71 | {7,8,9}  | {"region=europe-west1,az=b","region=europe-west1,az=c","region=europe-west1,az=d"} | {9,7,8}         | {}                  | {}               | NULL
  ...
  …/"washington dc"/PrefixEnd                                                       | …/<TableMax>                                                                      | \xf2891277617368696e67746f6e2064630002                                                               | \xf3                                                                                                 |      154 | {2,4,7}  | {"region=us-east1,az=c","region=us-west1,az=a","region=europe-west1,az=b"}         | {2,4,7}         | {}                  | {}               | NULL
(27 rows)
```

## See also

* <InternalLink path="show-range-for-row">`SHOW RANGE ... FOR ROW`</InternalLink>
* <InternalLink path="alter-table#split-at">`ALTER TABLE ... SPLIT AT`</InternalLink>
* <InternalLink path="alter-index#split-at">`ALTER INDEX ... SPLIT AT`</InternalLink>
* <InternalLink path="create-table">`CREATE TABLE`</InternalLink>
* <InternalLink path="create-index">`CREATE INDEX`</InternalLink>
* <InternalLink path="indexes">Indexes</InternalLink>
* <InternalLink path="partitioning">Partitioning tables</InternalLink>
* <InternalLink path="architecture/overview">Architecture Overview</InternalLink>
