SHOW DATABASES

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

The SHOW DATABASES statement lists all databases in the CockroachDB cluster.

Synopsis

SHOW DATABASES WITH COMMENT

Required privileges

The user must be granted the SELECT privilege to specific databases in order to list those databases in the CockroachDB cluster.

Example

Show databases

icon/buttons/copy
> SHOW DATABASES;
  database_name
+---------------+
  defaultdb
  movr
  postgres
  startrek
  system
(5 rows)

Alternatively, within the built-in SQL shell, you can use the \l shell command to list all databases:

icon/buttons/copy
> \l
  database_name
+---------------+
  defaultdb
  movr
  postgres
  startrek
  system
(5 rows)

Show databases with comments

You can use COMMENT ON to add comments on a database.

icon/buttons/copy
> COMMENT ON DATABASE movr IS 'This database holds information about users, vehicles, and rides.';

To view a database's comments:

icon/buttons/copy
> SHOW DATABASES WITH COMMENT;
  database_name |                              comment
+---------------+-------------------------------------------------------------------+
  defaultdb     | NULL
  movr          | This database holds information about users, vehicles, and rides.
  postgres      | NULL
  startrek      | NULL
  system        | NULL
(5 rows)

For more information, see COMMENT ON.

Preloaded databases

New clusters and existing clusters upgraded to v2.1 or later will include three auto-generated databases, with the following purposes:

  • The empty defaultdb database is used if a client does not specify a database in the connection parameters.

  • The movr database contains data about users, vehicles, and rides for the vehicle-sharing app MovR.

  • An empty database called postgres is provided for compatibility with Postgres client applications that require it.

  • The startrek database contains quotes from episodes.

  • The system database contains CockroachDB metadata and is read-only.

The postgres and defaultdb databases can be deleted if they are not needed.

See also


Yes No
On this page

Yes No