Is there a way to use the "COPY" (PostgreSQL) command in windows cli?

Trying to use the "copy" command for PostgreSQL in the windows cli command:

COPY myTable FROM value.txt (DELIMITER('|')); 

I can not find the "copy" executable in the bin directory.

Can you tell me how can I run the 'copy' command in cli?

Added: The copy function will be used in my Windows application. You must run it directly from the application.

Thanks in advance.

I managed to see my desired result using the following approach.

 psql.exe -f copy.sql -p 5433 -U user -s postgres copy.sql \copy TARGET_TABLE FROM source.txt (DELIMITER('#')); 
+5
source share
1 answer

You have the correct command ( COPY ), but you need to start an interactive session using Postgres if you want to use the COPY from the Windows command prompt.

 psql -U username yourdb 

This should leave you on a line resembling the following:

 yourdb=# 

Now you can use the COPY , and it should work:

 COPY myTable FROM value.txt (DELIMITER('|')) 

The problem you are facing is that COPY not a Windows executable, it is a Postgres command that only Postgres understands.

+4
source

Source: https://habr.com/ru/post/1238591/


All Articles