Re: importing db as text files - Mailing list pgsql-general

From Jason Godden
Subject Re: importing db as text files
Date
Msg-id 200308141450.41485.jasongodden@optushome.com.au
Whole thread Raw
In response to Re: importing db as text files  (expect <expect@ihubbell.com>)
Responses Re: importing db as text files  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
On Thu, 14 Aug 2003 02:17 pm, expect wrote:
> On Wed, 13 Aug 2003 14:59:29 -0700
>
> "Gregory S. Williamson" <gsw@globexplorer.com> wrote:
> > have to fix missing numeric values (if the column allows nulls why can't
> > the copy command accept an empty field, I wonder?), missing dates. In
> > other cases
>
> This seems to be the question I need answered as well.  Does anyone know
> the answer?

Copy can accept an empty field (representing null):

copy datatable from stdin delimiter '\t' null '';

by default pg expects '\N' to mean null but you can override it:

Description: copy data between files and tables
Syntax:
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' ] ]

Rgds,

Jason

pgsql-general by date:

Previous
From: Mike Mascari
Date:
Subject: Re: Why the duplicate messages to pgsql-general?
Next
From: expect
Date:
Subject: Re: Why the duplicate messages to pgsql-general?