Question about weird COPY syntax

Started by Evan Carrollalmost 16 years ago4 messagesgeneral
Jump to latest
#1Evan Carroll
me@evancarroll.com

Why is it that "DELIMITER", and "NULL" options are under [WITH] but
not under [CSV]. This seems at least slightly awkward.

Command: COPY
Description: copy data between a file and a table
Syntax:
COPY tablename [ ( column [, ...] ) ]
FROM { 'filename' | STDIN }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ]
[ CSV [ HEADER ] <-
Why not put them under this.
[ QUOTE [ AS ] 'quote' ]
[ ESCAPE [ AS ] 'escape' ]
[ FORCE NOT NULL column [, ...] ]

--
Evan Carroll
System Lord of the Internets
http://www.evancarroll.com

#2Evan Carroll
me@evancarroll.com
In reply to: Evan Carroll (#1)
Re: Question about weird COPY syntax

While asking questions about the grammar of COPY why do we have a
bracket of `[ [ WITH ] ...` rather than `[ WITH ]` ...

COPY tablename [ ( column [, ...] ) ]
FROM { 'filename' | STDIN }
[ [ WITH ] (why is this opening bracket that is never closed here.)
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ]
[ -PERL_key = value ]
[ -PERL_key ]
[ CSV [ HEADER ]
[ QUOTE [ AS ] 'quote' ]
[ ESCAPE [ AS ] 'escape' ]
[ FORCE NOT NULL column [, ...] ]
[ -TCSV_key ]
[ -TCSV_key = value ]

--
Evan Carroll
System Lord of the Internets
http://www.evancarroll.com

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Evan Carroll (#2)
Re: Question about weird COPY syntax

Evan Carroll <me@evancarroll.com> writes:

While asking questions about the grammar of COPY why do we have a
bracket of `[ [ WITH ] ...` rather than `[ WITH ]` ...

Somebody left out the closing brackets in the documentation, evidently.
Will fix.

regards, tom lane

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Evan Carroll (#1)
Re: Question about weird COPY syntax

Evan Carroll <me@evancarroll.com> writes:

Why is it that "DELIMITER", and "NULL" options are under [WITH] but
not under [CSV]. This seems at least slightly awkward.

They're not specific to CSV.

regards, tom lane