postgresql 是否有像“psql --quiet”这样的“pg_restore --quiet”选项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11485358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a "pg_restore --quiet" option like "psql --quiet"?
提问by Rob Bednark
psql
has a -q
/ --quiet
option (environment variable QUIET
). pg_restore
does not have a quiet option. Is there any way to make pg_restore
not verbosely show the SQL commands that it's executing?
psql
有一个-q
/--quiet
选项(环境变量QUIET
)。 pg_restore
没有安静的选择。有什么方法可以pg_restore
不详细显示它正在执行的 SQL 命令?
# e.g., here's the verbose output that I don't want to see:
$ pg_restore --cluster 8.4/mycluster mycluster.dump
---- PostgreSQL database dump
--
SET statement_timeout = 0;SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;SET check_function_bodies = false;
...
--
-- Name: data_src; Type: TABLE; Schema: public; Owner: postgres; Tablespace:--
CREATE TABLE data_src (
...
回答by Daniel Vérité
The question seems to imply that pg_restore
is executing these SQL commands and you wouldn't want to see them in the output. But outputting them is what it's only supposed to do.
这个问题似乎暗示pg_restore
正在执行这些 SQL 命令并且您不希望在输出中看到它们。但是输出它们只是它应该做的。
pg_restore
has two modes of operation, with or without connecting to a database. When it's called without a database (-d
option) as shown in the question:
pg_restore
有两种操作模式,连接或不连接数据库。当它在没有数据库(-d
选项)的情况下调用时,如问题所示:
$ pg_restore --cluster 8.4/mycluster mycluster.dump
$ pg_restore --cluster 8.4/mycluster mycluster.dump
then its sole purpose is to output a set of SQL commands in plain text that should be fed to an SQL interpreter to restore the database. Those SQL commands form a coherent set without any concept of verbosity, and they are not executedby pg_restore
itself. They're generally redirected into a file for later execution or piped into psql
for immediate execution.
那么它的唯一目的是以纯文本形式输出一组 SQL 命令,这些命令应该提供给 SQL 解释器以恢复数据库。这些SQL命令形成了一整套无冗长的任何概念,他们不执行的pg_restore
本身。它们通常被重定向到一个文件中以供稍后执行或通过管道输入psql
以立即执行。
回答by Ligemer
You can redirect stdout to a file:
您可以将标准输出重定向到文件:
pg_restore --cluster 8.4/mycluster mycluster.dump > pg_restore.log
Or provide the -d option, but what you want is either -f
or -d
或提供 -d 选项,但您想要的是-f
或-d
pg_restore -f pg_restore.sql --cluster 8.4/mycluster mycluster.dump
pg_restore -d yourdatabase --cluster 8.4/mycluster mycluster.dump