How to List Databases in PostgreSQL
Last updated July 25, 2026 · By the SaturnSQL team
In psql, \l (or \l+ for sizes) lists all databases on the server. From SQL, query pg_database; pg_database_size gives each database's on-disk size.
psql
\l shows every database on the server with its owner, encoding, collation, and access privileges, and \l+ adds size and tablespace. Both are psql meta-commands. Unlike MySQL, the list is not filtered by whether you can connect, so you will see databases you have no rights to.
\l
\l+Plain SQL (works from any client)
pg_database is a shared catalog, so this returns the same list from whichever database you happen to be connected to. Excluding datistemplate drops the internal template0 and template1. pg_database_size needs CONNECT privilege on each database and errors on ones you cannot reach, so add AND has_database_privilege(datname, 'CONNECT') to skip those.
SELECT datname,
pg_size_pretty(pg_database_size(datname)) AS size
FROM pg_database
WHERE NOT datistemplate
ORDER BY pg_database_size(datname) DESC;Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free