【问题标题】:PostgreSQL - How to suppress query statement messagePostgreSQL - 如何抑制查询语句消息
【发布时间】:2015-10-14 20:42:27
【问题描述】:

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

psql -U postgres -d rails_development -a -f ProjectApp/db/Query.sql

输出如下:

SELECT * FROM "Users"
id | username | firstname | lastname | [...]
...
(27 rows)

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

【问题讨论】:

  • 删除-a 标志。 (并且也许添加 -t 标志)注意:psql --help 为您提供所有可能的标志。

标签: sql postgresql command-line suppressmessage


【解决方案1】:

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

psql -U postgres -d rails_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
  ...

【讨论】:

    【解决方案2】:

    -a 选项重复终端上的每个查询 (STDOUT),您想从命令行中删除此选项。

    【讨论】:

      猜你喜欢
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-21
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多