Skip to main content
Use the SHOW PARTITIONS to view details about existing .
Most users should not need to use partitioning directly. Instead, they should use CockroachDB’s built-in , 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 .

Synopsis

show_partitions syntax diagram

Required privileges

No are required to list partitions.

Parameters

ParameterDescription
database_nameThe name of the for which to show .
table_nameThe name of the for which to show .
table_index_nameThe name of the for which to show .

Response

The following fields are returned for each partition:
FieldDescription
database_nameThe name of the database that contains the partition.
table_nameThe name of the table that contains the partition.
partition_nameThe name of the partition.
parent_partitionThe name of the parent partition, if the partition is a .
column_namesThe names of the columns in the partition definition expression.
index_nameThe name of the index for the partition.
partition_valueThe value that defines the partition.
zone_constraintsThe , if replication zones are configured for the 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 . To follow along, run 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 or .

Show table partitions

You can also use 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