Skip to main content
The SHOW REGIONS statement lists the cluster regions for a multi-region cluster, or the database regions for the databases in a multi-region cluster.

Synopsis

show_regions syntax diagram

Required privileges

Only members of the admin role can run SHOW REGIONS. By default, the root user belongs to the admin role.

Parameters

Response

SHOW REGIONS, SHOW REGIONS FROM CLUSTER, and SHOW REGIONS FROM DATABASE return the following fields for each region: SHOW REGIONS FROM ALL DATABASES returns the following fields for each database:

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 --nodes and --demo-locality flags. This command opens an interactive SQL shell to a temporary, multi-node in-memory cluster with the movr database preloaded and set as the current database.

View the regions in a cluster

After cluster startup, you can view all of the cluster regions available in the cluster with SHOW REGIONS FROM CLUSTER:

View the regions in a single database

SHOW REGIONS FROM DATABASE returns the database regions for a specific database. Add an available region as the primary region for the movr database:
Only cluster regions (i.e., regions that are defined at node startup time) can be added to a multi-region database.
Then, add more regions to the database:
To view the regions associated with the database:
The secondary column in each row says whether that region has been made a secondary region for failover purposes. For more information, see Secondary regions. With movr set as the current database, the following statement returns the same results:

View the regions for all databases in a cluster

Create another database in the cluster with a primary region:
Then, add another region to the database:
To show the regions in use by all the databases in a cluster, use SHOW REGIONS:
To show the region information for each database in the cluster, use SHOW REGIONS FROM ALL DATABASES:

See also