Re: [GENERAL] COPY ... FROM stdin WITH FORMAT csv - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] COPY ... FROM stdin WITH FORMAT csv
Date
Msg-id CAKFQuwZsS=aRJ8Ag3ThvUGmgUrmAJQC=d4keUYc2Se5o2z4M4w@mail.gmail.com
Whole thread Raw
In response to [GENERAL] COPY ... FROM stdin WITH FORMAT csv  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
On Tue, Mar 21, 2017 at 10:31 AM, Alexander Farber <alexander.farber@gmail.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.

pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: [GENERAL] COPY ... FROM stdin WITH FORMAT csv
Next
From: John R Pierce
Date:
Subject: Re: [GENERAL] COPY ... FROM stdin WITH FORMAT csv