Notes below
for more details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>LOG_VERBOSITY</literal></term>
<listitem>
<para>
Specifies the amount of messages emitted by a <command>COPY</command>
command: <literal>default</literal>, <literal>verbose</literal>, or
<literal>silent</literal>.
If <literal>verbose</literal> is specified, additional messages are
emitted during processing.
<literal>silent</literal> suppresses both verbose and default messages.
</para>
<para>
This is currently used in <command>COPY FROM</command> command when
<literal>ON_ERROR</literal> option is set to <literal>ignore</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>WHERE</literal></term>
<listitem>
<para>
The optional <literal>WHERE</literal> clause has the general form
<synopsis>
WHERE <replaceable class="parameter">condition</replaceable>
</synopsis>
where <replaceable class="parameter">condition</replaceable> is
any expression that evaluates to a result of type
<type>boolean</type>. Any row that does not satisfy this
condition will not be inserted to the table. A row satisfies the
condition if it returns true when the actual row values are
substituted for any variable references.
</para>
<para>
Currently, subqueries are not allowed in <literal>WHERE</literal>
expressions, and the evaluation does not see any changes made by the
<command>COPY</command> itself (this matters when the expression
contains calls to <literal>VOLATILE</literal> functions).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Outputs</title>
<para>
On successful completion, a <command>COPY</command> command returns a command
tag of the form
<screen>
COPY <replaceable class="parameter">count</replaceable>
</screen>
The <replaceable class="parameter">count</replaceable> is the number
of rows copied.
</para>
<note>
<para>
<application>psql</application> will print this command tag only if the command
was not <literal>COPY ... TO STDOUT</literal>, or the
equivalent <application>psql</application> meta-command
<literal>\copy ... to stdout</literal>. This is to prevent confusing the
command tag with the data that was just printed.
</para>
</note>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
<command>COPY TO</command> can be used with plain
tables and populated materialized views.
For example,
<literal>COPY <replaceable class="parameter">table</replaceable>
TO</literal> copies the same rows as
<literal>SELECT * FROM ONLY <replaceable class="parameter">table</replaceable></literal>.
However it doesn't directly support other relation types,
such as partitioned tables, inheritance child tables, or views.
To copy all rows from such relations, use <literal>COPY (SELECT * FROM
<replaceable class="parameter">table</replaceable>) TO</literal>.
</para>
<para>
<command>COPY FROM</command> can be used with plain, foreign, or
partitioned tables or with views that have
<literal>INSTEAD OF INSERT</literal> triggers.
</para>
<para>
You must have select privilege on the table
whose values are read by <command>COPY TO</command>, and
insert privilege on the table into which values
are inserted by <command>COPY FROM</command>. It is sufficient
to have column privileges on the column(s) listed in the command.
</para>
<para>
If row-level security is enabled for the table, the relevant
<command>SELECT</command> policies will apply to <literal>COPY
<replaceable class="parameter">table</replaceable> TO</literal> statements.
Currently, <command>COPY FROM</command> is not supported for tables
with row-level security. Use equivalent <command>INSERT</command>
statements