Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/alter_sequence.sgml`
dd839e045ff7918fa51b6e81d0ce80c4dce22d771a01e4350000000100000fa0
 name (optionally schema-qualified) of a sequence to be altered.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><literal>IF EXISTS</literal></term>
      <listitem>
       <para>
        Do not throw an error if the sequence does not exist. A notice is issued
        in this case.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">data_type</replaceable></term>
      <listitem>
       <para>
        The optional
        clause <literal>AS <replaceable class="parameter">data_type</replaceable></literal>
        changes the data type of the sequence.  Valid types are
        <literal>smallint</literal>, <literal>integer</literal>,
        and <literal>bigint</literal>.
       </para>

       <para>
        Changing the data type automatically changes the minimum and maximum
        values of the sequence if and only if the previous minimum and maximum
        values were the minimum or maximum value of the old data type (in
        other words, if the sequence had been created using <literal>NO
        MINVALUE</literal> or <literal>NO MAXVALUE</literal>, implicitly or
        explicitly).  Otherwise, the minimum and maximum values are preserved,
        unless new values are given as part of the same command.  If the
        minimum and maximum values do not fit into the new data type, an error
        will be generated.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">increment</replaceable></term>
      <listitem>
       <para>
        The clause <literal>INCREMENT BY <replaceable
        class="parameter">increment</replaceable></literal> is
        optional. A positive value will make an ascending sequence, a
        negative one a descending sequence.  If unspecified, the old
        increment value will be maintained.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">minvalue</replaceable></term>
      <term><literal>NO MINVALUE</literal></term>
      <listitem>
       <para>
        The optional clause <literal>MINVALUE <replaceable
        class="parameter">minvalue</replaceable></literal> determines
        the minimum value a sequence can generate. If <literal>NO
        MINVALUE</literal> is specified, the defaults of 1 and
        the minimum value of the data type for ascending and descending sequences,
        respectively, will be used.  If neither option is specified,
        the current minimum value will be maintained.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">maxvalue</replaceable></term>
      <term><literal>NO MAXVALUE</literal></term>
      <listitem>
       <para>
        The optional clause <literal>MAXVALUE <replaceable
        class="parameter">maxvalue</replaceable></literal> determines
        the maximum value for the sequence. If <literal>NO
        MAXVALUE</literal> is specified, the defaults of
        the maximum value of the data type and -1 for ascending and descending
        sequences, respectively, will be used.  If neither option is
        specified, the current maximum value will be maintained.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><literal>CYCLE</literal></term>
      <listitem>
       <para>
        The optional <literal>CYCLE</literal> key word can be used to enable
        the sequence to wrap around when the
        <replaceable class="parameter">maxvalue</replaceable> or
        <replaceable class="parameter">minvalue</replaceable> has been
        reached by
        an ascending or descending sequence respectively. If the limit is
        reached, the next number generated will be the
        <replaceable class="parameter">minvalue</replaceable> or
        <replaceable class="parameter">maxvalue</replaceable>,
       

Title: ALTER SEQUENCE Parameters
Summary
This section details the parameters for the ALTER SEQUENCE command, including: name (of the sequence), IF EXISTS (to avoid errors if the sequence doesn't exist), data_type (to change the sequence's data type to smallint, integer, or bigint), increment (to set the increment value), minvalue/NO MINVALUE (to define or reset the minimum value), maxvalue/NO MAXVALUE (to define or reset the maximum value).