Re: importing db as text files

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jason Godden <jasongodden(at)optushome(dot)com(dot)au>
Cc: expect <expect(at)ihubbell(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: importing db as text files
Date: 2003-08-14 13:57:25
Message-ID: 20030814135725.GE27870@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 14, 2003 at 14:50:41 +1000,
Jason Godden <jasongodden(at)optushome(dot)com(dot)au> wrote:
>
> Copy can accept an empty field (representing null):

That assumes that an empty field is what he means by 'no value'.
For some data types an empty string is a perfectly valid data type.

> copy datatable from stdin delimiter '\t' null '';
>
> by default pg expects '\N' to mean null but you can override it:

He wants the default value, not null though. Copy doesn't have a way
to specify a string to be replaced by the default value. It probably
wouldn't be too hard to add this option, but it is too late for 7.4.

If the default value is a constant preprocessing should be an easy way
to handle the issue. Another option may be to change null's to the
default after importing the data (assuming there aren't actual nulls
in the data). If he is trying to use nextval for all rows on one column,
then not entering that column would be the way to go.

We haven't seen any example of the data he is trying to import so it is
hard to give him specific advice.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-08-14 14:01:55 Re: importing db as text files
Previous Message Mel Roman 2003-08-14 13:50:23 Re: PostGreSQL - Accessing It