psql is a program used on a Unix shell to connect and manage your PostgreSQL database.
Before you use the psql command you need to have access to a remote shell through SSH.
Connecting to PostgreSQL using psql
First you need to know your connection details
Those will be given to you, when you create a new PostgreSQL database.
Once you have the details, you can write the connection command line, substituting fields as needed:
psql -h postgresql.guebs.net -U user_name-ddatabase_name
Press enter. The shell will ask for a password:
Password for useruser_name:
Press enter. If the password is correct, we will see something like this:
psql (9.4.8) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. database_name=>
Hereafter, you can execute the SQL queries or postgresql commands, to manage your database.
Commands inside psql
Source: Kartones Postgres cheatsheet
|Connect to a database||\c __base_datos__|
|Show table definition including triggers||\d __table__|
|Show function SQL code||\df+ __function|