Bulk loading into PostgreSQL from a remote client

Jon picture Jon · Aug 30, 2010 · Viewed 7.1k times · Source

I need to bulk load a large file into PostgreSQL. I would normally use the COPY command, but this file needs to be loaded from a remote client machine. With MSSQL, I can install the local tools and use bcp.exe on the client to connect to the server.

Is there an equivalent way for PostgreSQL? If not, what is the recommended way of loading a large file from a client machine if I cannot copy the file to the server first?

Thanks.

Answer

Pablo Santa Cruz picture Pablo Santa Cruz · Aug 30, 2010

COPY command is supported in PostgreSQL Protocol v3.0 (Postgresql 7.4 or newer).

The only thing you need to use COPY from a remote client is a libpq enabled client such as psql command line utility.

From the remote client run:

$ psql -d dbname -h 192.168.1.1 -U uname < yourbigscript.sql