Re: The COPY command and csv files

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Eric Matthew Finnin" <emf(dot)storage(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: The COPY command and csv files
Date: 2006-04-18 19:26:44
Message-ID: 18175.1145388404@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Eric Matthew Finnin" <emf(dot)storage(at)gmail(dot)com> writes:
> Apparently, you can't use the COPY command to copy a whole file
> without being a super user?

You can, but not like that. The point of the restriction is that the
database may be running on a different machine from where the user is,
and non-superusers shouldn't have access to the filesystem that the
database can see. "COPY FROM 'filename'" is a server-side operation
and reads the server's filesystem, so it's allowed only to superusers.

However, psql (and probably most other client-side tools) have a way
to read from the client's filesystem and shove the data across the
network to a COPY FROM STDIN command. In psql what you want is to
use the \copy command --- see the psql reference page for details.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Reza Razavipour 2006-04-18 20:42:59 Maximum database size
Previous Message George Young 2006-04-18 17:59:00 Re: Find all foreign keys and dropping them from a script.