Re: COPY command - Mailing list pgsql-sql

From Michael Glaesemann
Subject Re: COPY command
Date
Msg-id 3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com
Whole thread Raw
In response to Re: COPY command  (azwa@nc.com.my)
List pgsql-sql
On Jan 9, 2004, at 1:11 PM, azwa@nc.com.my wrote:
> how do we run the COPY command from file which has several null
> columns in each field.  
> thanks.
>
> example :
>
>    dwnc=# copy biosadm.custinv_temp
> dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ;
> ERROR:  copy: line 1, Missing data for column "subsidiary"  

Just like you specify the delimiter, you need to specify the value for
NULL. For example, if your *.txt file has a line with a "missing" value
(such as the space between 'bar' and 'foofoo')

foo    bar        foofoo    barbar

I usually use 'NULL' as NULL, so the line would be

foo    bar    NULL    foofoo    barbar

then use the COPY command with NULL AS 'NULL'

Check out the following link for detailed info on the COPY command:
<http://www.postgresql.org/docs/current/static/sql-copy.html>

HTH

Michael Glaesemann
grzm myrealbox com



pgsql-sql by date:

Previous
From: azwa@nc.com.my
Date:
Subject: Re: COPY command
Next
From: Robert Creager
Date:
Subject: Re: grouping by date