2

I use a file where I have all my SQL queries. I run the following command:

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

Output is as following:

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

I would like to remove query message (SELECT * FROM "Users") from output. Is that possible?

4

2 回答 2

4

-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
  ...
于 2015-10-14T20:51:29.443 回答
1

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

于 2015-10-14T20:53:06.460 回答