Skip to content

Commit f32c687

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 bf88c6d commit f32c687

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
@@ -411,10 +411,16 @@ COPY <replaceable class="parameter">count</replaceable>
411411
<title>Notes</title>
412412

413413
<para>
414-
<command>COPY TO</command> can only be used with plain tables, not
415-
with views. However, you can write <literal>COPY (SELECT * FROM
416-
<replaceable class="parameter">viewname</replaceable>) TO ...</literal>
417-
to copy the current contents of a view.
414+
<command>COPY TO</command> can be used only with plain
415+
tables, not views, and does not copy rows from child tables
416+
or child partitions. For example, <literal>COPY <replaceable
417+
class="parameter">table</replaceable> TO</literal> copies
418+
the same rows as <literal>SELECT * FROM ONLY <replaceable
419+
class="parameter">table</replaceable></literal>.
420+
The syntax <literal>COPY (SELECT * FROM <replaceable
421+
class="parameter">table</replaceable>) TO ...</literal> can be used to
422+
dump all of the rows in an inheritance hierarchy, partitioned table,
423+
or view.
418424
</para>
419425

420426
<para>
@@ -423,16 +429,6 @@ COPY <replaceable class="parameter">count</replaceable>
423429
<literal>INSTEAD OF INSERT</literal> triggers.
424430
</para>
425431

426-
<para>
427-
<command>COPY</command> only deals with the specific table named;
428-
it does not copy data to or from child tables. Thus for example
429-
<literal>COPY <replaceable class="parameter">table</replaceable> TO</literal>
430-
shows the same data as <literal>SELECT * FROM ONLY <replaceable
431-
class="parameter">table</replaceable></literal>. But <literal>COPY
432-
(SELECT * FROM <replaceable class="parameter">table</replaceable>) TO ...</literal>
433-
can be used to dump all of the data in an inheritance hierarchy.
434-
</para>
435-
436432
<para>
437433
You must have select privilege on the table
438434
whose values are read by <command>COPY TO</command>, and

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy