SHOW LOCALITY

On this page Carat arrow pointing down
Warning:
CockroachDB v19.2 is no longer supported as of May 12, 2021. For more details, refer to the Release Support Policy.

New in v19.2: The SHOW LOCALITY statement returns the locality of the current node.

If locality was not specified on node startup, the statement returns an empty row.

Tip:

In 19.1.x you can retrieve locality information using select * from crdb_internal.gossip_nodes;

Required privileges

No privileges are required to list the locality of the current node.

Synopsis

SHOW LOCALITY

Example

Setup

The following example uses 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 movr with the --nodes and --demo-locality tags. 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.

icon/buttons/copy
$ cockroach demo movr --nodes=3 --demo-locality=region=us-east,az=a:region=us-central,az=b:region=us-west1,az=c

Show locality

icon/buttons/copy
> SHOW LOCALITY;
       locality
+---------------------+
  region=us-east,az=a
(1 row)

Show locality with a built-in function

If you know the locality key, you can use the crdb_internal.locality_value built-in function to return the locality value for the current node:

icon/buttons/copy
> SELECT * FROM crdb_internal.locality_value('region');
  crdb_internal.locality_value
+------------------------------+
  us-east
(1 row)
icon/buttons/copy
> SELECT * FROM crdb_internal.locality_value('az');
  crdb_internal.locality_value
+------------------------------+
  a
(1 row)

For a more extensive example, see Create a table with node locality information.

See also


Yes No
On this page

Yes No