Re: COPY manual is ambiguous about column list

"David G. Johnston" <[email protected]> Thu, 19 Dec 2019 22:07:48 -0700
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <CAKFQuwaxE-m5VKQkOapv+3kMnP2Q9hEb0NbGeBfqkQuX3UmVgQ@mail.gmail.com>
--000000000000aa8600059a1ba96b
Content-Type: text/plain; charset="UTF-8"

On Thu, Dec 19, 2019 at 9:46 PM Tom Lane <[email protected]> wrote:

> Bruce Momjian <[email protected]> writes:
> > How is the attached patch?
>
> !    In <command>COPY FROM</command>, the number of columns specified
> !    must match the number of fields in the file;  any table columns not
> !    specified in the <command>COPY FROM</command> column list will insert
> !    their default values.
>
> Phrasing seems a bit weird to me: you've run two nearly independent
> observations into one sentence.  But s/; any/. Any/ might be enough
> to fix it.
>

Seems better to simply talk about each form independently:

If a list of columns is specified, <command>COPY TO</command> will only
copy the data in the specified columns to the file.  <command>COPY
FROM</command> will, by position (i.e., the number of columns listed must
match the number of columns in the file), match each file column to the
named column in the table.  Any additional columns present in the table
will receive their default value.

David J.

--000000000000aa8600059a1ba96b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon=
t-family:arial,helvetica,sans-serif"><span style=3D"font-family:Arial,Helve=
tica,sans-serif">On Thu, Dec 19, 2019 at 9:46 PM Tom Lane &lt;<a href=3D"ma=
ilto:[email protected]">[email protected]</a>&gt; wrote:</span><br></div></=
div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex">Bruce Momjian &lt;<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a>&gt; writes:<br>
&gt; How is the attached patch?<br>
<br>
!=C2=A0 =C2=A0 In &lt;command&gt;COPY FROM&lt;/command&gt;, the number of c=
olumns specified<br>
!=C2=A0 =C2=A0 must match the number of fields in the file;=C2=A0 any table=
 columns not<br>
!=C2=A0 =C2=A0 specified in the &lt;command&gt;COPY FROM&lt;/command&gt; co=
lumn list will insert<br>
!=C2=A0 =C2=A0 their default values.<br>
<br>
Phrasing seems a bit weird to me: you&#39;ve run two nearly independent<br>
observations into one sentence.=C2=A0 But s/; any/. Any/ might be enough<br=
>
to fix it.<br></blockquote><div><br></div><div class=3D"gmail_default" styl=
e=3D"font-family:arial,helvetica,sans-serif">Seems better to simply talk ab=
out each form independently:</div><div class=3D"gmail_default" style=3D"fon=
t-family:arial,helvetica,sans-serif"><br></div><div class=3D"gmail_default"=
 style=3D"font-family:arial,helvetica,sans-serif">If a list of columns is s=
pecified, &lt;command&gt;COPY TO&lt;/command&gt; will only copy the data in=
 the specified columns to the file.=C2=A0 &lt;command&gt;COPY FROM&lt;/comm=
and&gt; will, by position (i.e., the number of columns listed must match th=
e number of columns in the file), match each file column to the named colum=
n in the table.=C2=A0 Any additional columns present in the table will rece=
ive their default value.</div><div class=3D"gmail_default" style=3D"font-fa=
mily:arial,helvetica,sans-serif"><br></div><div class=3D"gmail_default" sty=
le=3D"font-family:arial,helvetica,sans-serif">David J.</div><div class=3D"g=
mail_default" style=3D"font-family:arial,helvetica,sans-serif"><br></div></=
div></div>

--000000000000aa8600059a1ba96b--