customize pager in psql

。_饼干妹妹 提交于 2019-12-02 23:46:42

From the fine psql manual:

\pset option [ value ]
[...]
pager
Controls use of a pager program for query and psql help output. If the environment variable PAGER is set, the output is piped to the specified program. Otherwise a platform-dependent default (such as more) is used.

When the pager option is off, the pager program is not used. When the pager option is on, the pager is used when appropriate

So you can say this from the psql prompt:

psql> \pset pager off

to turn the pager off. If you want this to always apply, you can add \pset pager off to your ~/.psqlrc file.

You can also use \? from the psql prompt to get a quick summary of the special commands at your disposal.

For completeness we might mention that for a one-off or to use as a setting in one of your scripts... (and as mentioned by "mu", see the psql --help (manual))

As a command in a script

psql --pset=pager-off -c "<sqlCommand>" <databaseName>

From your commandline

psql --pset=pager=off <databaseName>

This would be in effect for the single command only so it is most useful in a script.

You can use this method in lieu of making temporary changes within the psql utility or permanent settings via the init file (~/.psqlrc).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!