gpt4 book ai didi

sql - 运行 sql 文件而不打印其内容 POSTGRES

转载 作者:搜寻专家 更新时间:2023-10-30 21:57:28 27 4
gpt4 key购买 nike

如何在不将其内容打印到屏幕的情况下运行 .sql 文件我正在使用此命令运行 .sql 文件

psql -h localhost -U usrcashlink -d db_cashlink -a -f /home/cashlink/jenkins_node/cashlink_teste/cashlink_testes/src/test/resources/br/com/softbox/cashlink/massadados/massa_antes.sql

但是它正在将整个文件内容打印(记录)到屏幕上。如何在不打印其内容的情况下执行此 .sql 文件。

最佳答案

至少从您的调用中跳过选项 -a,从而代替:

psql -h localhost -U usrcashlink -d db_cashlink -a -f /path/to/file.sql

尝试:

psql -h localhost -U usrcashlink -d db_cashlink -f /path/to/file.sql

您可以随时询问 psql 参数的含义以及可用的内容。在我的系统上:

$ psql --help
psql is the PostgreSQL interactive terminal.

Usage:
psql [OPTION]... [DBNAME [USERNAME]]

General options:
-c, --command=COMMAND run only single command (SQL or internal) and exit
-d, --dbname=DBNAME database name to connect to (default: "sthagen")
-f, --file=FILENAME execute commands from file, then exit
-l, --list list available databases, then exit
-v, --set=, --variable=NAME=VALUE
set psql variable NAME to VALUE
(e.g., -v ON_ERROR_STOP=1)
-V, --version output version information, then exit
-X, --no-psqlrc do not read startup file (~/.psqlrc)
-1 ("one"), --single-transaction
execute as a single transaction (if non-interactive)
-?, --help[=options] show this help, then exit
--help=commands list backslash commands, then exit
--help=variables list special variables, then exit

Input and output options:
-a, --echo-all echo all input from script
-b, --echo-errors echo failed commands
-e, --echo-queries echo commands sent to server
-E, --echo-hidden display queries that internal commands generate
-L, --log-file=FILENAME send session log to file
-n, --no-readline disable enhanced command line editing (readline)
-o, --output=FILENAME send query results to file (or |pipe)
-q, --quiet run quietly (no messages, only query output)
-s, --single-step single-step mode (confirm each query)
-S, --single-line single-line mode (end of line terminates SQL command)

Output format options:
-A, --no-align unaligned table output mode
-F, --field-separator=STRING
field separator for unaligned output (default: "|")
-H, --html HTML table output mode
-P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command)
-R, --record-separator=STRING
record separator for unaligned output (default: newline)
-t, --tuples-only print rows only
-T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)
-x, --expanded turn on expanded table output
-z, --field-separator-zero
set field separator for unaligned output to zero byte
-0, --record-separator-zero
set record separator for unaligned output to zero byte

Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
-p, --port=PORT database server port (default: "5432")
-U, --username=USERNAME database user name (default: "sthagen")
-w, --no-password never prompt for password
-W, --password force password prompt (should happen automatically)

For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within psql, or consult the psql section in the PostgreSQL
documentation.

Report bugs to <pgsql-bugs@postgresql.org>.

另一个选项总是在 shell 级别,用于将标准输出和标准错误重定向到文件或 /dev/null 以完全不使用它......像这样:

psql -h localhost -U usrcashlink -d db_cashlink -f /path/to/file.sql 1>out.txt 2>err.txt 

关于sql - 运行 sql 文件而不打印其内容 POSTGRES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37550640/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com