Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/create_sequence.sgml`
cbc13ef94bdce7282870f86e8921ebd1229ce5c16dc0826a0000000100000fa9
 is 1.
     </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 this clause is not
      supplied or <option>NO MINVALUE</option> is specified, then
      defaults will be used.  The default for an ascending sequence is 1.  The
      default for a descending sequence is the minimum value of the data type.
     </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 this clause is not
      supplied or <option>NO MAXVALUE</option> is specified, then
      default values will be used.  The default for an ascending sequence is
      the maximum value of the data type.  The default for a descending
      sequence is -1.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>CYCLE</literal></term>
    <term><literal>NO CYCLE</literal></term>
    <listitem>
     <para>
      The <literal>CYCLE</literal> option allows 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>, respectively.
     </para>

     <para>
      If <literal>NO CYCLE</literal> is specified, any calls to
      <function>nextval</function> after the sequence has reached its
      maximum value will return an error.  If neither
      <literal>CYCLE</literal> or <literal>NO CYCLE</literal> are
      specified, <literal>NO CYCLE</literal> is the default.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">start</replaceable></term>
    <listitem>
     <para>
      The optional clause <literal>START WITH <replaceable
      class="parameter">start</replaceable> </literal> allows the
      sequence to begin anywhere.  The default starting value is
      <replaceable class="parameter">minvalue</replaceable> for
      ascending sequences and <replaceable
      class="parameter">maxvalue</replaceable> for descending ones.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">cache</replaceable></term>
    <listitem>
     <para>
      The optional clause <literal>CACHE <replaceable
      class="parameter">cache</replaceable></literal> specifies how
      many sequence numbers are 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), and this is also the
      default.
     </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.  The specified table must have the same owner and be in
      the same schema as the sequence.
      <literal>OWNED BY NONE</literal>,

Title: CREATE SEQUENCE Parameters: Max Value, Cycle, Start, Cache, Owned By
Summary
This section describes more parameters for the CREATE SEQUENCE command: maxvalue/NO MAXVALUE (maximum sequence value), CYCLE/NO CYCLE (whether sequence wraps around at max/min), start (initial sequence value), cache (number of preallocated sequence numbers), and OWNED BY (associates sequence with a table column for automatic dropping).