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 and works similarly in all environments. This makes it an ideal choice for developing portable applications and techniques.

psql provides features for use as both an interactive query tool and a scripting tool.

Getting ready

From here on, we will assume that psql is a sufficient command to allow you access to the PostgreSQL server. This assumes that all of your connection parameters are defaults, which may not be true.

Written in full, the connection parameters would be as follows:

psql –h hostname –p 5432 –d dbname –U username

The default value for the port (-p) is 5432. By default, dbname and username are both ...

Get PostgreSQL 9 Administration Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.