Thread: copy syntax

copy syntax

From
Andy Chambers
Date:
dcm_eob=> copy ar_data from '/tmp/ar-data.csv' with header true;
ERROR:  syntax error at or near "true"
LINE 1: copy ar_data from '/tmp/ar-data.csv' with header true;

I can't figure out what's wrong with the syntax above.  Is something missing?

--
Andy Chambers
Software Engineer
(e) achambers@mcna.net
(t) 954-682-0573

CONFIDENTIALITY NOTICE: This electronic mail may contain information
that is privileged, confidential, and/or otherwise protected from
disclosure to anyone other than its intended recipient(s). Any
dissemination or use of this electronic mail or its contents by
persons other than the intended recipient(s) is strictly prohibited.
If you have received this communication in error, please notify the
sender immediately by reply e-mail so that we may correct our internal
records. Please then delete the original message. Thank you.

Re: copy syntax

From
Guillaume Lelarge
Date:
On Wed, 2012-04-04 at 16:01 -0400, Andy Chambers wrote:
> dcm_eob=> copy ar_data from '/tmp/ar-data.csv' with header true;
> ERROR:  syntax error at or near "true"
> LINE 1: copy ar_data from '/tmp/ar-data.csv' with header true;
>
> I can't figure out what's wrong with the syntax above.  Is something missing?
>

Yes, you need parentheses, like this:

copy ar_data from '/tmp/ar-data.csv' with (header true);


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com


Re: copy syntax

From
Andreas
Date:
Am 04.04.2012 22:01, schrieb Andy Chambers:
> dcm_eob=>  copy ar_data from '/tmp/ar-data.csv' with header true;
> ERROR:  syntax error at or near "true"
> LINE 1: copy ar_data from '/tmp/ar-data.csv' with header true;
>
> I can't figure out what's wrong with the syntax above.  Is something missing?
>

copy  ar_data
from   $$/tmp/ar-data.csv$$
csv header delimiter ';'
;

... providet it's not a REAL csv as in "comma separated ..."
... $$ works better as ' at leas when you need to have backslashes in
the path.
... and you'll need to mind the encoding of the CSV if you use some
international signs