PostgreSQL - 如何抑制查询语句消息

Rar*_*are 4 sql postgresql command-line suppressmessage

我使用一个包含所有 SQL 查询的文件。我运行以下命令:

psql -U postgres -d rails_development -a -f ProjectApp/db/Query.sql
Run Code Online (Sandbox Code Playgroud)

输出如下:

SELECT * FROM "Users"
id | username | firstname | lastname | [...]
...
(27 rows)
Run Code Online (Sandbox Code Playgroud)

我想从输出中删除查询消息(SELECT * FROM“Users”)。那可能吗?

zed*_*xus 6

-a--echo-all回显脚本中的所有输入。你不需要那个。包含--tuples-only-t标志以仅打印行,如下所示:

psql -U postgres -drails_development --tuples-only -f ProjectApp/db/Query.sql

psql --help说:

...
Input and output options:
  -a, --echo-all           echo all input from script
  -e, --echo-queries       echo commands sent to server
  ...

Output format options:
  ...
  -R, --record-separator=STRING
                           set record separator (default: newline)
  -t, --tuples-only        print rows only
  ...
Run Code Online (Sandbox Code Playgroud)