How to list all PostgreSQL databases and their sizes in MB

You must provide proper database name and user:


File: gistfile1.txt
-------------------

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