On Fri, Apr 29, 2016 at 10:31 AM, Andrei M. Eichler
<andrei.eichler@unicheck.com.br> wrote:
> 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';
The syntax synopsis in the current docs requires parentheses around
any options. I was a little surprised that you got it to work at
all without them; but then remembered there is older (deprecated
and undocumented) syntax that was not ripped out to avoid breaking
code which was working before the syntax change in 9.0. To do this
per the current documentation (which I would strongly recommend
over the old, undocumented, deprecated syntax), try this:
COPY test_copy FROM '/mnt/disk1/files/test_file.csv' with (
format csv,
header true,
delimiter ';',
force_null (date_column, date_column2, date_column3, date_column4,
date_column5),
encoding 'latin1'
);
This new syntax was adopted to make it easier to add new options,
and to avoid having to define new keywords or reserved words to do
so.
It's not really a question of whether we should go back to
documenting the deprecated syntax, but whether (and when) support
for it should finally be ripped out. It was last documented in 8.4.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company