我有两个都运行 PG 9.4 的数据库实例
当我在一个数据库中发出COPY
命令时,它将返回受影响的行数,但是在设置相同的第二个数据库中它不会返回。
我在配置中没有看到任何不同或可能影响的内容。导入不会出错,并且在两个帐户上都成功导入。
Documentation声明只要它不是标准输出就应该返回。
文档中的这一行看起来相关,但我不确定它是否适用于我的情况。
Do not confuse COPY with the psql instruction \copy. \copy invokes COPY FROM STDIN or COPY TO STDOUT, and then fetches/stores the data in a file accessible to the psql client. Thus, file accessibility and access rights depend on the client rather than the server when \copy is used.
我发出的命令是:
COPY [tablename] from '/var/lib/pgsql/datafile.csv'
目前我正在研究 Putty session 变量,但我不确定这是正确的方法。
有人知道为什么会发生这种情况吗?
最佳答案
当 psql 安静时,它不会显示这些消息。
使用-q
或\set QUIET on
激活安静模式
示例:
test=# copy test to '/tmp/foo';
COPY 8
test=# \set QUIET on
test=# copy test to '/tmp/foo';
test=#
关于postgresql - COPY 命令不返回行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48155993/