> ## 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 LOCALITY

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 LOCALITY` <InternalLink path="sql-statements">statement</InternalLink> returns the <InternalLink path="cockroach-start#locality">locality</InternalLink> of the current node.

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

## Required privileges

No <InternalLink path="security-reference/authorization#managing-privileges">privileges</InternalLink> are required to list the locality of the current node.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/8savutSe7Roc6oQ0/images/sql-diagrams/v26.2/show_locality.svg?fit=max&auto=format&n=8savutSe7Roc6oQ0&q=85&s=231d818a2a805098c32dca1fb9e06cc4" alt="show_locality syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="231" height="37" data-path="images/sql-diagrams/v26.2/show_locality.svg" />

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

To follow along, run <InternalLink path="cockroach-demo">`cockroach demo movr`</InternalLink> 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 <InternalLink path="sql-name-resolution#current-database">current database</InternalLink>.

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach demo movr --nodes=3 --demo-locality=region=us-east,az=a:region=us-central,az=b:region=us-west1,az=c
```

### Show locality

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> 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 <InternalLink path="functions-and-operators">`crdb_internal.locality_value`</InternalLink> built-in function to return the locality value for the current node:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM crdb_internal.locality_value('region');
```

```
  crdb_internal.locality_value
+------------------------------+
  us-east
(1 row)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM crdb_internal.locality_value('az');
```

```
  crdb_internal.locality_value
+------------------------------+
  a
(1 row)
```

For a more extensive example, see <InternalLink path="cockroach-start#create-a-table-with-node-locality-information">Create a table with node locality information</InternalLink>.

## See also

* <InternalLink path="cockroach-start#locality">Locality</InternalLink>
* <InternalLink path="kubernetes-overview">Orchestrated Deployment</InternalLink>
* <InternalLink path="manual-deployment">Manual Deployment</InternalLink>
