Skip to main content
Use the SHOW PARTITIONS statement to view details about existing partitions.
Most users should not need to use partitioning directly. Instead, they should use CockroachDB’s built-in multi-region capabilities, which automatically handle geo-partitioning and other low-level details.
In testing, scripting, and other programmatic environments, we recommend querying the crdb_internal.partitions internal table for partition information instead of using the SHOW PARTITIONS statement. For more information, see Querying partitions programmatically.

Synopsis

show_partitions syntax diagram

Required privileges

No privileges are required to list partitions.

Parameters

Response

The following fields are returned for each partition:

Examples

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.
The movr database in this example is pre-partitioned. For information about partitioning tables, see Define Table Partitions or ALTER TABLE... PARTITION BY.

Show table partitions

You can also use SHOW CREATE TABLE to view partitions on a table:
If a partitioned table has no zones configured, the SHOW CREATE TABLE output includes a warning.

Show partitions by index

Show partitions by database

Querying partitions programmatically

The crdb_internal.partitions internal table contains information about the partitions in your database. In testing, scripting, and other programmatic environments, we recommend querying this table for partition information instead of using the SHOW PARTITIONS statement. For example, to get all us_west partitions of in your database, you can run the following query:
Other internal tables, like crdb_internal.tables, include information that could be useful in conjunction with crdb_internal.partitions. For example, if you want the output for your partitions to include the name of the table and database, you can perform a join of the two tables:

See also