Re: COPY options

From: "Andrei M(dot) Eichler" <andrei(dot)eichler(at)unicheck(dot)com(dot)br>
To: Kevin Grittner <kgrittn(at)gmail(dot)com>
Cc: "pgsql-docs(at)postgresql(dot)org" <pgsql-docs(at)postgresql(dot)org>
Subject: Re: COPY options
Date: 2016-04-29 15:31:37
Message-ID: CABS=F1+hjzqLgkx23p6RqPkyim_c2GOdMdsBZgGj27qAwwEyxw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hi, thanks for the wiki link.

I'm using Postgrees 9.5.2, running on Debian 8.4

I have a csv file with all columns quoted, even null values.

Following the documentation, I wrote this COPY FROM command:

COPY test_copy FROM '/mnt/disk1/files/test_file.csv' with csv header
delimiter ';' force_null date_column, date_column2, date_column3,
date_column4, date_column5 encoding 'latin1';

And received this error message:

ERROR: syntax error at or near "force_null"
LINE 1: ...test_file.csv' with csv header delimiter ';' force_null...

To fix the error, I had to replace the "_" to " ", so "force_null" becomes
"force null" :

COPY test_copy FROM '/mnt/disk1/files/test_file.csv' with csv header
delimiter ';' force null date_column, date_column2, date_column3,
date_column4, date_column5 encoding 'latin1';

COPY 99999

In the docs (http://www.postgresql.org/docs/current/static/sql-copy.html)
the "FORCE" options are written with "_" but the correct name is with " "

2016-04-28 17:27 GMT-03:00 Kevin Grittner <kgrittn(at)gmail(dot)com>:

> On Thu, Apr 28, 2016 at 11:58 AM, Andrei M. Eichler
> <andrei(dot)eichler(at)unicheck(dot)com(dot)br> wrote:
>
> > when one tries to use it as it is from the docs, one gets the following
> > results:
> > ERROR: syntax error at or near "force_null"
>
> Works for me.
>
> Please copy/paste the actual command and the actual, complete error
> message.
>
> https://wiki.postgresql.org/wiki/Guide_to_reporting_problems
>
> --
> Kevin Grittner
> EDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2016-04-29 15:50:38 Re: COPY options
Previous Message Kevin Grittner 2016-04-28 20:27:22 Re: COPY options