psql
Pager
Set it to off to show the output in the main screen:
database-devel=# \pset pager off
NULL
Set it to the value you want psql to show for NULL values:
database-devel=# \pset null '--NULL--'
Extended output
Set it to on
to show all values of a record in multiple lines. Set it to off
to show all values of a record in one line (default).
database-devel=# \x # Alternatively: '\x on'
Expanded display is on.
database-devel=# \x # Alternatively: '\x off'
Expanded display is off.
Send output to a file
We can send the result of a query to a file:
database-devel=# \o /tmp/query-result.txt
database-devel=# SELECT count(id) FROM table;
database-devel=# \o
This way the result will be saved to /tmp/query-result.txt
. Use \o
again to send the output back to the terminal.