psql -d postgres -c "SELECT pg_size_pretty(pg_database_size('appdb'));"

Category: Databases & SQL

psql -d postgres -c "SELECT pg_size_pretty(pg_database_size('appdb'));"

Show the size of one database

pg_database_size returns the bytes a database occupies on disk; pg_size_pretty formats it as 123 MB. The database must exist or the query errors. Compare databases by joining pg_database.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.