Skip to content

Commit 48cbed8

Browse files
committed
doc: clarify COPY TO for partitioning/inheritance
It was not clear how COPY TO behaved with partitioning/inheritance because the paragraphs were so far apart. Also reword to simplify. Discussion: https://postgr.es/m/20201203211723.GR24052@telsasoft.com Author: Justin Pryzby Backpatch-through: 10
1 parent 355f9d2 commit 48cbed8

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

doc/src/sgml/ref/copy.sgml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,16 @@ COPY <replaceable class="parameter">count</replaceable>
396396
<title>Notes</title>
397397

398398
<para>
399-
<command>COPY TO</command> can only be used with plain tables, not
400-
with views. However, you can write <literal>COPY (SELECT * FROM
401-
<replaceable class="parameter">viewname</replaceable>) TO ...</literal>
402-
to copy the current contents of a view.
399+
<command>COPY TO</command> can be used only with plain
400+
tables, not views, and does not copy rows from child tables
401+
or child partitions. For example, <literal>COPY <replaceable
402+
class="parameter">table</replaceable> TO</literal> copies
403+
the same rows as <literal>SELECT * FROM ONLY <replaceable
404+
class="parameter">table</replaceable></literal>.
405+
The syntax <literal>COPY (SELECT * FROM <replaceable
406+
class="parameter">table</replaceable>) TO ...</literal> can be used to
407+
dump all of the rows in an inheritance hierarchy, partitioned table,
408+
or view.
403409
</para>
404410

405411
<para>
@@ -408,16 +414,6 @@ COPY <replaceable class="parameter">count</replaceable>
408414
<literal>INSTEAD OF INSERT</literal> triggers.
409415
</para>
410416

411-
<para>
412-
<command>COPY</command> only deals with the specific table named;
413-
it does not copy data to or from child tables. Thus for example
414-
<literal>COPY <replaceable class="parameter">table</replaceable> TO</literal>
415-
shows the same data as <literal>SELECT * FROM ONLY <replaceable
416-
class="parameter">table</replaceable></literal>. But <literal>COPY
417-
(SELECT * FROM <replaceable class="parameter">table</replaceable>) TO ...</literal>
418-
can be used to dump all of the data in an inheritance hierarchy.
419-
</para>
420-
421417
<para>
422418
You must have select privilege on the table
423419
whose values are read by <command>COPY TO</command>, and

0 commit comments

Comments
 (0)