Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group