Trying to use 'copy' command of PostgreSQL in windows cli command:
COPY myTable FROM value.txt (DELIMITER('|'));
I can't find 'copy' executable file in bin directory.
Can you let me know how can I run 'copy' command in cli?
Added: My windows application is going to use the 'Copy' feature. Need to run it directly from Application.
Thanks in advance.
I could manage to see my required result with following approach.
psql.exe -f copy.sql -p 5433 -U user -s postgres
copy.sql
\copy TARGET_TABLE FROM source.txt (DELIMITER('#'));
The PostgreSQL \copy command is a meta-command available from the psql interactive client tool. You can use \copy to import data into a table on your RDS for PostgreSQL DB instance.
The easiest but the most efficient way to export data from a Postgres table to a CSV file is by using the COPY command. COPY command generates a CSV file on the Database Server. You can export the entire table or the results of a query to a CSV file with the COPY TO command.
You have the right command (COPY
), but you need to begin an interactive session with Postgres if you want use the COPY
command from the Windows command line.
psql -U username yourdb
This should leave you at a prompt looking like the following:
yourdb=#
Now you can use the COPY
command and it should work:
COPY myTable FROM value.txt (DELIMITER('|'))
The problem you were having is that COPY
is not a Windows executable program, it is a Postgres command which is only understood by Postgres.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With