List databases on PostgreSQL instance

Query below lists databases on PostgresSQL instance.

Query

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

Columns

  • database_id - databalase id, unique within an instance of PostgreSQL
  • database_name - database name
  • allow_connect - indicate if anybody can connect to database
  • connection_limit - shows maximum number of concurrent connections to database (-1 means no limit)

Rows

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

Sample results

View of databases in pgAdmin. Blue rectangle shows databases.

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.