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

时间:2015-10-14 20:42:28

标签: sql postgresql command-line suppressmessage

我使用的文件中包含所有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")。这可能吗?

2 个答案:

答案 0 :(得分: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
  ...

答案 1 :(得分:1)

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