Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am a novice in psql and need some help. How can I load a local CSV to a remote DB?

I am using the following command

\COPY test(user_id, product_id, value) 
      FROM '/Users/testuser/test.tsv' WITH DELIMITER '\t' CSV HEADER;

but this searches the file on the remote DB while I need to do that on my local PC.

share|improve this question
2  
\copy reads a local file (it's a psql command and can only be used from inside psql). COPY however (note the missing ``) will read the file on the server. – a_horse_with_no_name Apr 4 at 14:53
so there is no way to this? i need to copy the file to the remote server? – user22149 Apr 4 at 14:58
is there any difference in copy and \copy? sorry i am really new in psql only know oracle there i can do this without any problem – user22149 Apr 4 at 15:02
Well the difference is, that one reads the file on the server and the other is reading the file on the client. Obviously reading the file on the server will be faster. – a_horse_with_no_name Apr 4 at 15:07
thanks for the quick reply and could you tell me how i can load a tsv? when i say delimiter '\t' it says ERROR: COPY delimiter must be a single one-byte character \copy: ERROR: COPY delimiter must be a single one-byte character – user22149 Apr 4 at 15:47
show 2 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.