PostgreSQL – List all databases

Run the below query to view all the databases in Postgres.

select oid as db_id, datname as db_name, datallowconn from pg_database;

datallowconn is a boolean column. Users can connect to a database only if datallowconn is ‘true’.

See also  PostgreSQL - Get current value and next value of a Sequence