Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/ref/alter_sequence.sgml`
9506940edd0d28b9b7398172a7560ae3ab5a6ee7076f3d26000000010000098d

        or last set by <command>ALTER SEQUENCE START WITH</command>.
       </para>

       <para>
        In contrast to a <function>setval</function> call,
        a <literal>RESTART</literal> operation on a sequence is transactional
        and blocks concurrent transactions from obtaining numbers from the
        same sequence. If that's not the desired mode of
        operation, <function>setval</function> should be used.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">cache</replaceable></term>
      <listitem>
       <para>
        The clause <literal>CACHE <replaceable
        class="parameter">cache</replaceable></literal> enables
        sequence numbers to be preallocated and stored in memory for
        faster access. The minimum value is 1 (only one value can be
        generated at a time, i.e., no cache).  If unspecified, the old
        cache value will be maintained.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><literal>SET { LOGGED | UNLOGGED }</literal></term>
      <listitem>
       <para>
        This form changes the sequence from unlogged to logged or vice-versa
        (see <xref linkend="sql-createsequence"/>).  It cannot be applied to a
        temporary sequence.
       </para>
      </listitem>
     </varlistentry>

   <varlistentry>
    <term><literal>OWNED BY</literal> <replaceable class="parameter">table_name</replaceable>.<replaceable class="parameter">column_name</replaceable></term>
    <term><literal>OWNED BY NONE</literal></term>
    <listitem>
     <para>
      The <literal>OWNED BY</literal> option causes the sequence to be
      associated with a specific table column, such that if that column
      (or its whole table) is dropped, the sequence will be automatically
      dropped as well.  If specified, this association replaces any
      previously specified association for the sequence.  The specified
      table must have the same owner and be in the same schema as the
      sequence.
      Specifying <literal>OWNED BY NONE</literal> removes any existing
      association, making the sequence <quote>free-standing</quote>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">new_owner</replaceable></term>
    <listitem>
     <para>
      The user name of the new owner of the sequence.
     </para>

Title: ALTER SEQUENCE Parameters (Continued): CACHE, LOGGED/UNLOGGED, OWNED BY
Summary
This section describes the remaining parameters for the ALTER SEQUENCE command, including CACHE for pre-allocating sequence numbers, SET LOGGED/UNLOGGED to change the logging status of the sequence (not applicable to temporary sequences), and OWNED BY to associate the sequence with a table column for automatic deletion when the column or table is dropped.