From: | Dimitri Fontaine <dim(at)dalibo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Arnaud Lesauvage <thewild(at)freesurf(dot)fr> |
Subject: | Re: COPY FROM and NULL AS does not work |
Date: | 2006-12-01 11:01:56 |
Message-ID: | 200612011201.59158.dim@dalibo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Le vendredi 1 décembre 2006 11:28, Arnaud Lesauvage a écrit :
> HI List,
>
> Trying to import data from a text file, with a semicolon as
> the delimiter, double-quotes as the quoting character.
>
> I would like empty strings to be inserted as NULL values in
> a varchar column. In the text file, they are writen as :
> <some columns>;"";<some columns>
As soon as you quote a string, COPY will consider it not to be NULL, but empty
string if there's no content.
You have to express NULL as ;; with your settings, as shown here:
pgloader=# create table tmptable(one varchar, two varchar);
CREATE TABLE
pgloader=# copy tmptable from stdin DELIMITER AS ';' NULL AS '' CSV QUOTE
AS '"';
Entrez les données à copier suivies d'un saut de ligne.
Terminez avec un antislash et un point seuls sur une ligne.
>> ;""
>> ;""
>> \.
pgloader=# select * from tmptable where one is null;
one | two
-----+-----
|
|
(2 lignes)
Regards,
--
Dimitri Fontaine
http://www.dalibo.com/
From | Date | Subject | |
---|---|---|---|
Next Message | surabhi.ahuja | 2006-12-01 11:48:50 | Re: sudden drop in delete performance |
Previous Message | Richard Huxton | 2006-12-01 10:53:02 | Re: Restoring database from files on disk |