Skip to content

Posts from the ‘Postgresql’ Category

3
Feb

Postgresql – command line to return a single size value of databases

Return the total size usage of a particular database

psql -c "SELECT pg_database_size(pg_database.datname) FROM pg_database WHERE pg_database.datname = 'MyDatabase'; " -t -h localhost -U postgres

Return the total size usage of all the databases

psql -c "SELECT sum(pg_database_size(pg_database.datname)) FROM pg_database;" -t -h localhost -U postgres;

screen