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.