pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Glaesemann <grzm@myrealbox.com>
To: azwa@nc.com.my
Cc: pgsql-sql@postgresql.org
Subject: Re: COPY command
Date: Fri, 9 Jan 2004 13:49:45 +0900
Message-ID: <3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com> (raw)
In-Reply-To: <OF2D668522.07AE1BC2-ONFFFFFF44.0032688D@nc.com.my>
References: <OF2D668522.07AE1BC2-ONFFFFFF44.0032688D@nc.com.my>


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




view thread (8+ messages)

Message-ID: <3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com>
Permalink:  ../3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com/
Also on:    postgresql.org/message-id/3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: grzm@myrealbox.com, azwa@nc.com.my
  Subject: Re: COPY command
  In-Reply-To: <3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com>
  References: <OF2D668522.07AE1BC2-ONFFFFFF44.0032688D@nc.com.my> <3EE27553-425F-11D8-9330-000A95C88220@myrealbox.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox