So today we’ll try to learn a few things on PostgreSql and
see what exactly PostgreSql ‘Helper commands’ are.
Apart from the good old sql queries that you can certainly use,
PostgreSql also provides us with Helper commands which you can use
to fetch information from the PostgreSql DB.
You can fire the PostgreSql Helper commands from the PostgreSql command prompt.
So lets login into the PostgreSql command prompt.
psql is the command line utility you would need for this, so lets begin.
Open Terminal (`ctrl+alt+t` in Ubuntu, check for you particular distro)
psql -h <host_name> -p <port_number> -d <database_name> -U <db_user_name> -W
Type in your <db_password> in the password prompt.
So now since we have connected to out database, lets see a few commands.
Check for All the Databases on the server
Check for size and access privileges of a particular Database
List Tables in a DB
List Tables in a DB with Size
Details about a particular table
Describe a Table in a DB
Describe table with size and description (with pg_catalog schema)
Change/connect/move to a different Database.
Will try to come up with more blog post where we can share our information with each other.
Please let us know if you have any comments about the blog in the comments section below or if there are any corrections you may have spotted and you would like us to make those corrections.
Thanks a lot for taking your time & stopping over at the blogpost.
Have a good day!