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

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 DATABASES` <InternalLink path="sql-statements">statement</InternalLink> lists all databases in the CockroachDB cluster.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/Bc-7BE4092mn9J_1/images/sql-diagrams/v23.2/show_databases.svg?fit=max&auto=format&n=Bc-7BE4092mn9J_1&q=85&s=512f6065e51187cd41f57cd672ffa9e6" alt="show_databases syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="469" height="69" data-path="images/sql-diagrams/v23.2/show_databases.svg" />

<img src="https://mintcdn.com/cockroachlabs/9fwI5CGIlllYUI83/images/generated/docs/v23.2/show-databases/syntax-diagram-d61187770b72.svg?fit=max&auto=format&n=9fwI5CGIlllYUI83&q=85&s=d0801adf9148b51d3e6102985bfa2fc9" alt="SQL syntax diagram" width="469" height="69" data-path="images/generated/docs/v23.2/show-databases/syntax-diagram-d61187770b72.svg" />

## Required privileges

The user must be granted the `CONNECT` <InternalLink path="security-reference/authorization#managing-privileges">privilege</InternalLink> to specific databases in order to list those databases in the CockroachDB cluster.

## Example

### Show databases

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW DATABASES;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  database_name | owner | primary_region | secondary_region | regions | survival_goal
----------------+-------+----------------+------------------+---------+----------------
  defaultdb     | root  | NULL           | NULL             | {}      | NULL
  movr          | demo  | NULL           | NULL             | {}      | NULL
  postgres      | root  | NULL           | NULL             | {}      | NULL
  system        | node  | NULL           | NULL             | {}      | NULL
(4 rows)
```

Alternatively, within the built-in SQL shell, you can use the `\l` <InternalLink path="cockroach-sql#commands">shell command</InternalLink> to list all databases:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> \l
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  database_name | owner | primary_region | secondary_region | regions | survival_goal
----------------+-------+----------------+------------------+---------+----------------
  defaultdb     | root  | NULL           | NULL             | {}      | NULL
  movr          | demo  | NULL           | NULL             | {}      | NULL
  postgres      | root  | NULL           | NULL             | {}      | NULL
  system        | node  | NULL           | NULL             | {}      | NULL
(4 rows)
```

### Show databases with comments

You can use <InternalLink path="comment-on">`COMMENT ON`</InternalLink> to add comments on a database.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
COMMENT ON DATABASE movr IS 'This database holds information about users, vehicles, and rides.';
```

To view a database's comments:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW DATABASES WITH COMMENT;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   database_name | owner | primary_region | secondary_region | regions | survival_goal |                              comment
----------------+-------+----------------+------------------+---------+---------------+--------------------------------------------------------------------
  defaultdb     | root  | NULL           | NULL             | {}      | NULL          | NULL
  movr          | demo  | NULL           | NULL             | {}      | NULL          | This database holds information about users, vehicles, and rides.
  postgres      | root  | NULL           | NULL             | {}      | NULL          | NULL
  system        | node  | NULL           | NULL             | {}      | NULL          | NULL
(4 rows)
```

For more information, see <InternalLink path="comment-on">`COMMENT ON`</InternalLink>.

## Preloaded databases

New clusters and existing clusters <InternalLink path="upgrade-cockroach-version">upgraded</InternalLink> to v23.2 or later will include auto-generated databases, with the following purposes:

* The empty `defaultdb` database is used if a client does not specify a database in the <InternalLink path="connection-parameters">connection parameters</InternalLink>.
* The `movr` database contains data about users, vehicles, and rides for the vehicle-sharing app <InternalLink path="movr">MovR</InternalLink> (only when the cluster is started using the <InternalLink path="cockroach-demo">`demo` command</InternalLink> ).
* The empty `postgres` database is provided for compatibility with PostgreSQL client applications that require it.
* The `system` database contains CockroachDB metadata and is read-only.

All databases except for the `system` database can be <InternalLink path="drop-database">deleted</InternalLink> if they are not needed.

<Danger>
  Do not query the `system` database directly. Instead, use objects within the <InternalLink path="system-catalogs">system catalogs</InternalLink>.
</Danger>

## See also

* <InternalLink path="comment-on">`COMMENT ON`</InternalLink>
* <InternalLink path="show-schemas">`SHOW SCHEMAS`</InternalLink>
* <InternalLink path="information-schema">Information Schema</InternalLink>
* <InternalLink path="sql-statements">SQL Statements</InternalLink>
