PostgreSQL禁用更多输出 [英] PostgreSQL disable more output
问题描述
我正在PostgreSQL服务器上运行脚本:
I am running a script on my PostgreSQL server:
psql db -f sql.sql
来自 bash
或 cron
脚本。
它一直尝试使用更多
或更少
。
如何在 psql
中禁用结果分页?
How do I disable result pagination in psql
?
我要做的就是更改数据,我不在乎任何输出。
All I want to do is change the data, I don't care about any output.
推荐答案
要禁用分页,但是保留输出,使用:
To disable pagination but retain the output, use:
\pset pager off
要记住此设置,请将其添加到您的〜/ .psqlrc 。
To remember this setting, add it to your ~/.psqlrc.
请参见 psql手册。
在较早版本的Pg上,它只是一个切换,因此 \pset寻呼机
On older versions of Pg it was just a toggle, so \pset pager
要完全禁止查询输出,请使用 \ o在
。 psql
脚本中/ dev / null
To completely suppress query output, use \o /dev/null
in your psql
script.
抑制 psql
的信息输出,使用 -q
运行它或设置 QUIET = 1
在环境中。
To suppress psql
's informational output, run it with -q
or set QUIET=1
in the environment.
要产生结果并将其丢弃,可以使用以下命令将 stdout
重定向到 / dev / null
:
To produce results and throw them away you can redirect stdout
to /dev/null
with:
psql db -f sql.sql >/dev/null
您可以使用以下命令重定向stdout和stderr:
You can redirect both stdout and stderr with:
psql db -f sql.sql >&/dev/null
但我不建议这样做,因为它会丢弃可能警告您某些错误的错误信息。您还会产生结果并将其丢弃,这效率很低;您最好不要只是通过调整查询来首先生成它们。
but I don't recommend that, as it'll throw away error information that might warn you something isn't going right. You're also producing results and throwing them away, which is inefficient; you're better off just not producing them in the first place by adjusting your queries.
这篇关于PostgreSQL禁用更多输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!