Using the psql query and scripting tool
psql
 is the query tool supplied as a part of the core distribution of PostgreSQL, so it is available in all environments and works similarly in all of them. This makes it an ideal choice for developing portable applications and techniques.
psql
 provides features for use as both an interactive query tool and as a scripting tool.
Getting ready
From here on, we will assume that the psql
 command is enough to allow you access to the PostgreSQL server. This assumes that all your connection parameters are defaults, which may not be true.
Written in full, the connection parameters will be either of these options:
psql -h myhost -p 5432 -d mydb -U myuser psql postgresql://myuser@myhost:5432/mydb
The default value for the port (-p
) is 5432
. By default, mydb
 and myuser
 are both identical to the operating system›s username. The default myhost
 on Windows...