2011/07/11

postgres tips: copy and \copy

Below explanation is quoted from http://wiki.postgresql.org/wiki/COPY

COPY is the Postgres method of data-loading. Postgres's COPY comes in two separate variants, COPY and \COPY: COPY is server based, \COPY is client based.

COPY will be run by the PostgreSQL backend (user "postgres"). The backend user requires permissions to read & write to the data file in order to copy from/to it.You need to use an absolute pathname with COPY.

\COPY on the other hand, runs under the current $USER, and with that users environment. And \COPY can handle relative pathnames. The psql \COPY is accordingly much easier to use if it handles what you need.

No comments:

Post a Comment

100