Re: using copy to insert data.

From: Antti Haapala <haapala(at)mail(dot)student(dot)oulu(dot)fi>
To: Jennifer Lee <jlee(at)scri(dot)sari(dot)ac(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: using copy to insert data.
Date: 2003-02-06 17:00:08
Message-ID: Pine.GSO.4.44.0302061853010.24627-100000@paju.oulu.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


> I'm trying to insert data from a delimited file using the copy command
> (COPY table FROM 'filepath') this works fine, but I would like to insert
> data into specific columns. I've read that this is possible but haven't
> been able to find documentation on how to do it. I've been able to
> insert the data as I'd like in two steps. 1. copy into a temporary table, 2.
> insert using select columns from the temporary table. Is there a way to
> do this in one step?

This functionality is supported as of 7.3.

The syntax for COPY in brand new 7.3.2 docs is

COPY table [ ( column [, ...] ) ]
FROM { 'filename' | stdin }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ] ]

COPY table [ ( column [, ...] ) ]
TO { 'filename' | stdout }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ] ]

--
Antti Haapala

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Steve_Miller 2003-02-06 17:01:35 Re: Favorite Linux Editor for PostgreSQL Scripts?
Previous Message Steve_Miller 2003-02-06 16:52:10 Re: Favorite Linux Editor for PostgreSQL Scripts?/keyboards