Home Explore Blog CI



postgresql

6th chunk of `doc/src/sgml/ref/copy.sgml`
2686b449a6c3e2dac5c80861b66fa22c18c9b6cdc81f742f0000000100000faa
 values against the null string, even
      if it has been quoted, and if a match is found set the value to
      <literal>NULL</literal>. In the default case where the null string is empty,
      this converts a quoted empty string into NULL.
      If <literal>*</literal> is specified, the option will be applied to all columns.
      This option is allowed only in <command>COPY FROM</command>, and only when
      using <literal>CSV</literal> format.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>ON_ERROR</literal></term>
    <listitem>
     <para>
      Specifies how to behave when encountering an error converting a column's
      input value into its data type.
      An <replaceable class="parameter">error_action</replaceable> value of
      <literal>stop</literal> means fail the command, while
      <literal>ignore</literal> means discard the input row and continue with the next one.
      The default is <literal>stop</literal>.
     </para>
     <para>
      The <literal>ignore</literal> option is applicable only for <command>COPY FROM</command>
      when the <literal>FORMAT</literal> is <literal>text</literal> or <literal>csv</literal>.
     </para>
     <para>
      A <literal>NOTICE</literal> message containing the ignored row count is
      emitted at the end of the <command>COPY FROM</command> if at least one
      row was discarded. When <literal>LOG_VERBOSITY</literal> option is set to
      <literal>verbose</literal>, a <literal>NOTICE</literal> message
      containing the line of the input file and the column name whose input
      conversion has failed is emitted for each discarded row.
      When it is set to <literal>silent</literal>, no message is emitted
      regarding ignored rows.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>REJECT_LIMIT</literal></term>
    <listitem>
     <para>
      Specifies the maximum number of errors tolerated while converting a
      column's input value to its data type, when <literal>ON_ERROR</literal> is
      set to <literal>ignore</literal>.
      If the input causes more errors than the specified value, the <command>COPY</command>
      command fails, even with <literal>ON_ERROR</literal> set to <literal>ignore</literal>.
      This clause must be used with <literal>ON_ERROR</literal>=<literal>ignore</literal>
      and <replaceable class="parameter">maxerror</replaceable> must be positive <type>bigint</type>.
      If not specified, <literal>ON_ERROR</literal>=<literal>ignore</literal>
      allows an unlimited number of errors, meaning <command>COPY</command> will
      skip all erroneous data.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>ENCODING</literal></term>
    <listitem>
     <para>
      Specifies that the file is encoded in the <replaceable
      class="parameter">encoding_name</replaceable>.  If this option is
      omitted, the current client encoding is used. See the 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>

Title: COPY Command Parameters: FORCE_NULL, ON_ERROR, REJECT_LIMIT, ENCODING, LOG_VERBOSITY, WHERE
Summary
This section continues detailing parameters for the COPY command. It covers how to force NULL values based on string matching (FORCE_NULL), specifies error handling behavior (ON_ERROR) and sets a limit for tolerated errors with ON_ERROR set to ignore (REJECT_LIMIT). It also allows for specifying file encoding (ENCODING), controlling the verbosity of logging messages (LOG_VERBOSITY) and the addition of a WHERE clause for filtering rows.