Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/copy.sgml`
323bdc9ea61dbe6c6e6e3e51a443428725d3116cfe84ef7c0000000100000fa3
 results are to be copied.  Note that parentheses are required
      around the query.
     </para>
     <para>
      For <command>INSERT</command>, <command>UPDATE</command>,
      <command>DELETE</command>, and <command>MERGE</command> queries a
      <literal>RETURNING</literal> clause must be provided, and the target
      relation must not have a conditional rule, nor an
      <literal>ALSO</literal> rule, nor an <literal>INSTEAD</literal> rule
      that expands to multiple statements.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">filename</replaceable></term>
    <listitem>
     <para>
      The path name of the input or output file.  An input file name can be
      an absolute or relative path, but an output file name must be an absolute
      path.  Windows users might need to use an <literal>E''</literal> string and
      double any backslashes used in the path name.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>PROGRAM</literal></term>
    <listitem>
     <para>
      A command to execute. In <command>COPY FROM</command>, the input is
      read from standard output of the command, and in <command>COPY TO</command>,
      the output is written to the standard input of the command.
     </para>
     <para>
      Note that the command is invoked by the shell, so if you need to pass
      any arguments that come from an untrusted source, you
      must be careful to strip or escape any special characters that might
      have a special meaning for the shell. For security reasons, it is best
      to use a fixed command string, or at least avoid including any user input
      in it.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>STDIN</literal></term>
    <listitem>
     <para>
      Specifies that input comes from the client application.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>STDOUT</literal></term>
    <listitem>
     <para>
      Specifies that output goes to the client application.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">boolean</replaceable></term>
    <listitem>
     <para>
      Specifies whether the selected option should be turned on or off.
      You can write <literal>TRUE</literal>, <literal>ON</literal>, or
      <literal>1</literal> to enable the option, and <literal>FALSE</literal>,
      <literal>OFF</literal>, or <literal>0</literal> to disable it.  The
      <replaceable class="parameter">boolean</replaceable> value can also
      be omitted, in which case <literal>TRUE</literal> is assumed.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>FORMAT</literal></term>
    <listitem>
     <para>
      Selects the data format to be read or written:
      <literal>text</literal>,
      <literal>csv</literal> (Comma Separated Values),
      or <literal>binary</literal>.
      The default is <literal>text</literal>.
      See <xref linkend="sql-copy-file-formats"/> below for details.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>FREEZE</literal></term>
    <listitem>
     <para>
      Requests copying the data with rows already frozen, just as they
      would be after running the <command>VACUUM FREEZE</command> command.
      This is intended as a performance option for initial data loading.
      Rows will be frozen only if the table being loaded has been created
      or truncated in the current subtransaction, there are no cursors
      open and there are no older snapshots held by this transaction.  It is
      currently not possible to perform a <command>COPY FREEZE</command> on
      a partitioned table or foreign table.
      This option is only allowed in <command>COPY FROM</command>.
     </para>
     <para>
      Note that all other sessions will immediately be able to see the

Title: COPY Command Parameters: Filename, PROGRAM, STDIN/STDOUT, Booleans, FORMAT, and FREEZE
Summary
This section details the parameters for the COPY command, including specifying the filename for input/output, executing a program for data transfer, using STDIN/STDOUT for client application interaction, boolean values for enabling/disabling options, selecting the data format (text, CSV, or binary), and the FREEZE option for initial data loading by freezing rows.