Skip to content

February 3, 2015

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

by Joe Kuan

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

Advertisements
Read more from Postgresql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: