Re: importing db as text files

From: Jason Godden <jasongodden(at)optushome(dot)com(dot)au>
To: expect <expect(at)ihubbell(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: importing db as text files
Date: 2003-08-14 04:50:41
Message-ID: 200308141450.41485.jasongodden@optushome.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)globexplorer(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message expect 2003-08-14 04:55:14 Re: Why the duplicate messages to pgsql-general?
Previous Message Mike Mascari 2003-08-14 04:38:39 Re: Why the duplicate messages to pgsql-general?