禁用psql输出中的NOTICES[英] disable NOTICES in psql output

本文是小编为大家收集整理的关于禁用psql输出中的NOTICES的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

如何停止PSQL(PostgreSQL客户端)输出通知?例如

psql:schema/auth.sql:20:注意:创建表/主键将为表"用户"创建隐式索引" users_pkey"

我认为,除非有错误或其他原因输出内容,否则程序应保持沉默.

推荐答案

SET client_min_messages TO WARNING;

that 只能设置为会话或用 a>或

否则您可以将其放在 psqlrc" .psqlrc" .psqlrc" .psqlrc" <.

其他推荐答案

可能最全面的解释可能是在彼得·艾森特拉特(Peter Eisentrauts)上博客条目在这里(存档)

我强烈鼓励对原始博客进行研究和消化,但最终建议是:

PGOPTIONS='--client-min-messages=warning' psql -X -q -a -1 -v ON_ERROR_STOP=1 --pset pager=off -d mydb -f script.sql

其他推荐答案

使用--quiet启动PSQL.

通知并非没有用,但这是我的观点.

本文地址:https://www.itbaoku.cn/post/597695.html

问题描述

How do I stop psql (PostgreSQL client) from outputting notices? e.g.

psql:schema/auth.sql:20: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"

In my opinion a program should be silent unless it has an error, or some other reason to output stuff.

推荐答案

SET client_min_messages TO WARNING;

That could be set only for the session or made persistent with ALTER ROLE or ALTER DATABASE.

Or you could put that in your ".psqlrc".

其他推荐答案

Probably the most comprehensive explanation is on Peter Eisentrauts blog entry here (Archive)

I would strongly encourage that the original blog be studied and digested but the final recommendation is something like :

PGOPTIONS='--client-min-messages=warning' psql -X -q -a -1 -v ON_ERROR_STOP=1 --pset pager=off -d mydb -f script.sql

其他推荐答案

Use --quiet when you start psql.

A notice is not useless, but that's my point of view.