Skip to content
Advertisement

PostgreSQL psql terminal command

I’m trying to get psql to format nicely and am following the docs here. Right now, whenever I do a query on tables with lots of columns, no matter how big I make my screen each line overflows into the next line and producing a whole screen of unreadable junk.

The docs (link is above) say there’s a way to align columns nicely for more readable output.

Normally, to start psql, I just type:

psql

and hit Enter. Now I’m trying:

psql pset format aligned

And getting an error:

could not change directory to "/root"
psql: warning: extra command-line argument "aligned" ingored
psql: FATAL: Indent authentication failed for user "format"

Any ideas as to how I could get these command-line args to work for me?

Advertisement

Answer

These are not command line args. Run psql. Manage to log into database (so pass the hostname, port, user and database if needed). And then write it in the psql program.

Example (below are two commands, write the first one, press enter, wait for psql to login, write the second):

psql -h host -p 5900 -U username database
pset format aligned
Advertisement