Thread: Copy from problem

Copy from problem

From
Eduardo Vázquez Rodríguez
Date:
Hi I try to "copy from" a plain text file that looks someting like this:

John Red (\t) Garden Grove (\t) jwayne@garden.com
Jessie Rodriguez (\t) West Beach
Jane Harrison (\t) Malibu (\t) jharrison@malibu.com

Deliberately I missed the email info in the second line, I try to copy into
a table that has the following structure:

CREATE TABLE public."Example"
(
  "Name" varchar(30),
  "Adress" varchar(60),
  "Email" varchar(30),
) WITHOUT OIDS;


When I issue the following command
copy public."Example" from '/home/postgres/abc.txt';

The following error appears

ERROR:  missing data for column "Email"
CONTEXT:  COPY Prueba, line 2: "Jessie Rodriguez    Santa Anna "

My question is how can I insert a null value into the field email,and that
copy from continue copying the next lines?

Re: Copy from problem

From
Oliver Elphick
Date:
On Mon, 2004-05-24 at 18:54, Eduardo Vázquez Rodríguez wrote:
> When I issue the following command
> copy public."Example" from '/home/postgres/abc.txt';
>
> The following error appears
>
> ERROR:  missing data for column "Email"
> CONTEXT:  COPY Prueba, line 2: "Jessie Rodriguez    Santa Anna "
>
> My question is how can I insert a null value into the field email,and that
> copy from continue copying the next lines?

Null values are represented by \N (or by some other string specified in
the COPY command - see its documentation).

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "Do all things without murmurings and disputings;
      that ye may be blameless and harmless, the sons of
      God, without rebuke, in the midst of a crooked and
      perverse nation, among whom ye shine as lights in the
      world."    Philippians 2:14,15