List databases on Redshift instance

Query below lists databases on Amazon Redshift instance.

Query

select oid as database_id,
       datname as database_name,
       datallowconn as allow_connect
from pg_database
order by oid;

Columns

  • database_id - databalase id, unique within an instance of Redshift
  • database_name - database name
  • allow_connect - indicate if anybody can connect to database

Rows

  • One row represents one database
  • Scope of rows: all databases, including system databases
  • Ordered by database id

Sample results

View of databases in DBeaver. If you don't see Database Navigator tab than click on the Window -> Database Navigator.