Execute COPY command in remote database using local file

余生颓废 提交于 2019-12-24 03:47:09

问题


I'm trying to execute the Postgres COPY command.

COPY warehouse_terminal.test_table FROM 'C:\file.csv' DELIMITERS E'\t'
     CSV HEADER QUOTE E'\"' ESCAPE E'\\' NULL AS '';

The problem is, the db where I'm going to use this is remote, and the file "file.csv" is in my local machine in C:\. As a result, the file is not read.
Remote db, but local file. How can I get this working?


回答1:


Use \copy of the psql client on your local machine, it's a wrapper for COPY for just this purpose.

More details:

  • Problems while importing a txt file into postgres using php


来源:https://stackoverflow.com/questions/26007401/execute-copy-command-in-remote-database-using-local-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!