You can enter the following psql meta-command to get some details about a specified database, including its size:

\l+ <database_name>

And to get sizes of all databases (that you can connect to):

\l+
Answer from Ashish on Stack Overflow
🌐
Database Guide
database.guide › get-the-size-of-all-databases-in-postgresql-psql
Get the Size of All Databases in PostgreSQL (psql)
When using psql with PostgreSQL, we can use the \list+ command to return information about all databases on the server.
🌐
SQL Conjuror
sqlconjuror.com › home › postgresql – get the size of all databases
PostgreSQL – Get the Size of All Databases | SQL Conjuror
November 14, 2022 - Here is a script to get the size of all your PostgreSQL databases. SELECT d.datname AS Name, pg_catalog.pg_get_userbyid(d.datdba) AS Owner, CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') THEN pg_catalog.pg_size_pretty( pg_catalog.pg_database_size(d.datname) ) ELSE 'No Access' END AS SIZE FROM pg_catalog.pg_database d ORDER BY CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT') THEN pg_catalog.pg_database_size(d.datname) ELSE NULL END DESC; Cheers!
🌐
Beekeeper Studio
beekeeperstudio.io › blog › how-to-list-databases-in-postgres
How to List Databases Using the psql command line tool | Beekeeper Studio
April 21, 2024 - SELECT datname AS database_name, pg_size_pretty(pg_database_size(datname)) AS size, datallowconn AS allow_connections, datconnlimit AS connection_limit, encoding, datcollate, datctype FROM pg_catalog.pg_database; ... This query provides insights into the database’s configurations and settings. Beekeeper Studio lists all databases in a dropdown at the top of the interface, switch between databases at any time. ... In summary, list all the databases in psql using \l.
🌐
Postgresscripts
postgresscripts.com › post › list-and-organize-your-postgresql-databases-by-size-with-access-check
List PostgreSQL Databases by Size with Access Check | Postgres Scripts
April 1, 2024 - A critical aspect of this organization is understanding the storage footprint of each database. This SQL code snippet empowers you to efficiently retrieve a list of all your PostgreSQL databases, sorted by their size in descending order, while also indicating whether you have access to connect to each database.
🌐
Peterbe.com
peterbe.com › plog › show-size-of-every-postgresql-database
Show size of every PostgreSQL database you have - Peterbe.com
tl;dr; SELECT pg_database.datname, pg_database_size(pg_database.datname), pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database ORDER by 2 DESC;
🌐
Commandlinefu
commandlinefu.com › commands › view › 9792 › list-all-databases-in-postgres-and-their-bytehuman-sizes-ordering-by-byte-size-descending
List all databases in Postgres and their (byte/human) sizes, ordering by byte size descending
November 30, 2011 - psql -c \"SELECT pg_database.datname, pg_database_size(pg_database.datname), pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database ORDER BY pg_database_size DESC;\" -d - (List all databases in Postgres and their (byte/human) sizes, ordering by byte size descending Get a listing of all of your databases in Postgres and their sizes, ordering by the largest size first.
🌐
Datashelter
datashelter.tech › home › blog › list postgresql databases from the command line
List PostgreSQL Databases from the Command Line | Datashelter
April 30, 2026 - Last reviewed: April 30, 2026. ... psql -U [username] -c "SELECT datname, pg_size_pretty(pg_database_size(datname)) AS size FROM pg_database ORDER BY pg_database_size(datname) DESC;"
Find elsewhere
🌐
CommandPrompt Inc.
commandprompt.com › education › how-to-get-database-size-and-table-size-in-postgresql
How to Get Database Size and Table Size in PostgreSQL — CommandPrompt Inc.
August 24, 2022 - In PostgreSQL, built-in functions like pg_database_size(), pg_relation_size(), and pg_total_relation_size() are used to get the database and table size. The pg_total_relation_size() function is used to fetch the total size of a relation including ...
Address   2950 Newmarket ST STE 101 - 231, 98226, Bellingham
🌐
Atlassian
atlassian.com › data › admin › how to list databases and tables in postgresql using psql
How to List databases and tables in PostgreSQL using psql
Once you’ve connected to a database, you will want to inspect which tables have been created there. This can be done with the \dt meta-command. However, if there are no tables you will get no output. ... After creating a table, it will be returned in a tabular list of created tables.
🌐
Database Guide
database.guide › 2-ways-to-get-the-size-of-a-database-in-postgresql
2 Ways to Get the Size of a Database in PostgreSQL
... he PG_DATABASE_SIZE() function, you must have CONNECT privilege on the specified database (which is granted by default) or be a member of the pg_read_all_stats role. If you’re using psql, you can run the \l+ command. ... List of databases +--------+----------+----------+-------------...
🌐
A2 Hosting
a2hosting.com › kb › developer-corner › postgresql › determining-the-size-of-postgresql-databases-and-tables
The Best Web Hosting Services at 20x Speeds | hosting.com
Our platform offers a wide range of services that support websites and projects of all sizes. From your first visitor to your millionth, we have a plan for you. ... Trusted by over 700,000 customers to power 3,000,000+ websites! ... Tailored for creators, trusted by agencies and built to scale with enterprises.
🌐
DB Pro
dbpro.app › learn › postgres › guides › list-databases
PostgreSQL list databases | DB Pro
| Task | Command | |------|---------| | List all databases (psql) | \l | | List with sizes (psql) | \l+ | | List matching a pattern (psql) | \l myapp* | | List from the shell | psql -l | | List via SQL | SELECT datname FROM pg_database | | Exclude template databases | Add WHERE datistemplate = false | | Check if a database exists | SELECT EXISTS (SELECT 1 FROM pg_database WHERE datname = 'name') | | Get database size | SELECT pg_size_pretty(pg_database_size('name')) | | Connect to a database | \c dbname |
🌐
Database Tutorials
dbtut.com › home › postgresql
How to Find The Size of all Databases in PostgreSQL - Database Tutorials
October 31, 2019 - In Postgres you could be managing many databases on a Cluster. In some cases you may need to query the size all of these databases. You can query the size of a database or all databases in the cluster with the help of the following scripts. Find the Size of a Database in PostgreSQL SELECT
🌐
GeeksforGeeks
geeksforgeeks.org › postgresql-size-of-a-database
PostgreSQL - Size of a Database - GeeksforGeeks
April 15, 2025 - In PostgreSQL, viewing a list of ... DATABASES statement like MySQL. Instead, you can use the \l or \l+ commands in psql or query the pg_database view to display all databases....
🌐
Linuxize
linuxize.com › home › postgresql › how to list postgresql databases and tables using psql
How to List PostgreSQL Databases and Tables using psql | Linuxize
April 16, 2026 - If you want to get information about the sizes of the databases, default tablespaces, and descriptions use \l+ or \list+. The database size is shown only if the current user can connect to it.
🌐
KB Hosting
kb.hosting.com › developer corner › postgresql › determining the size of postgresql databases and tables
Determining the size of PostgreSQL databases and tables - hosting.com
3 weeks ago - You can use the psql command-line program to determine the sizes of PostgreSQL databases and tables. To do this, follow these steps: Log in to your account using SSH. At the command line, type the following command. Replace dbname with the name of the database, and username with the database username:
🌐
DB Vis
dbvis.com › thetable › postgres-list-databases
How To List Databases in PostgreSQL: A Complete Guide
February 5, 2025 - Use l+ or list+ to get additional information about each database, such as the size in Kb and its description: ... If the command line is not your thing, remember that you can also list databases in PostgreSQL by querying pg_catalog.pg_database.