If you want to use the complete query. You can use this:
\l+ <db_name>
You will get the size of the database as well as some details about the database.
To find the size of all the databases, use this code:
\l+
To query with the postgresql helper commands, You need to go into the postgresql command prompt
To Check other postgresql helper commands, use this syntax:
\?
at the postgresql command prompt.