Re: COPY ... FROM stdin WITH FORMAT csv

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: COPY ... FROM stdin WITH FORMAT csv
Date: 2017-03-21 17:49:02
Message-ID: CAKFQuwZsS=aRJ8Ag3ThvUGmgUrmAJQC=d4keUYc2Se5o2z4M4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Mar 21, 2017 at 10:31 AM, Alexander Farber <
alexander(dot)farber(at)gmail(dot)com> wrote:

> Good evening,
>
> I keep rereading https://www.postgresql.org/docs/9.6/static/sql-copy.html
> but just can't figure the proper syntax to put some records into the table:
> ​[...]​
>
> words=> COPY words_reviews (uid, author, nice, review, updated) FROM stdin
> WITH FORMAT 'csv';
> ERROR: syntax error at or near "FORMAT"
> LINE 1: ...d, author, nice, review, updated) FROM stdin WITH FORMAT 'cs...
>
>
​​[ [ WITH ] ( option [, ...] ) ]

The above means the entire "WITH" section is optional, as is the word
WITH. However, if you want to add "with" options they must appear within
parentheses, those are not optional. Multiple options can appear within
the single set of parentheses.

"""
FORMAT
Selects the data format to be read or written: text, csv (Comma Separated
Values), or binary. The default is text.
"""

Valid values for format are as listed, no single quote required (not sure
about if they are allowed)

Therefore:

WITH (FORMAT csv)

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2017-03-21 17:51:26 Re: COPY ... FROM stdin WITH FORMAT csv
Previous Message Alexander Farber 2017-03-21 17:31:36 COPY ... FROM stdin WITH FORMAT csv