PostgreSQL disable more output

后端 未结 6 1979
时光说笑
时光说笑 2020-12-04 08:56

I am running a script on my PostgreSQL server:

psql db -f sql.sql

from bash or in a cron script.

It keeps

6条回答
  •  我在风中等你
    2020-12-04 09:19

    To disable pagination but retain the output, use:

    \pset pager off
    

    To remember this setting, add it to your ~/.psqlrc.

    See the psql manual.

    On older versions of Pg it was just a toggle, so \pset pager

    To completely suppress query output, use \o /dev/null in your psql script.

    To suppress psql's informational output, run it with -q or set QUIET=1 in the environment.


    To produce results and throw them away you can redirect stdout to /dev/null with:

    psql db -f sql.sql >/dev/null
    

    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.

提交回复
热议问题