Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/create_sequence.sgml`
fb329a593242e6a2cff503a981c1d75fc856147493b6f0d40000000100000fa2
 <literal>TEMP</literal></term>
    <listitem>
     <para>
      If specified, the sequence object is created only for this
      session, and is automatically dropped on session exit.  Existing
      permanent sequences with the same name are not visible (in this
      session) while the temporary sequence exists, unless they are
      referenced with schema-qualified names.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>UNLOGGED</literal></term>
    <listitem>
     <para>
      If specified, the sequence is created as an unlogged sequence.  Changes
      to unlogged sequences are not written to the write-ahead log.  They are
      not crash-safe: an unlogged sequence is automatically reset to its
      initial state after a crash or unclean shutdown.  Unlogged sequences are
      also not replicated to standby servers.
     </para>

     <para>
      Unlike unlogged tables, unlogged sequences do not offer a significant
      performance advantage.  This option is mainly intended for sequences
      associated with unlogged tables via identity columns or serial columns.
      In those cases, it usually wouldn't make sense to have the sequence
      WAL-logged and replicated but not its associated table.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>IF NOT EXISTS</literal></term>
    <listitem>
     <para>
      Do not throw an error if a relation with the same name already exists.
      A notice is issued in this case. Note that there is no guarantee that
      the existing relation is anything like the sequence that would have
      been created &mdash; it might not even be a sequence.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">name</replaceable></term>
    <listitem>
     <para>
      The name (optionally schema-qualified) of the sequence to be created.
     </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>
      specifies the data type of the sequence.  Valid types are
      <literal>smallint</literal>, <literal>integer</literal>,
      and <literal>bigint</literal>.  <literal>bigint</literal> is the
      default.  The data type determines the default minimum and maximum
      values of the sequence.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">increment</replaceable></term>
    <listitem>
     <para>
      The optional clause <literal>INCREMENT BY <replaceable
      class="parameter">increment</replaceable></literal> specifies
      which value is added to the current sequence value to create a
      new value.  A positive value will make an ascending sequence, a
      negative one a descending sequence.  The default value 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

Title: CREATE SEQUENCE Parameters: Temporary, Unlogged, IF NOT EXISTS, Name, Data Type, Increment, Minimum Value
Summary
This section describes the parameters for the CREATE SEQUENCE command. It covers TEMPORARY/TEMP (sequence exists only for the session), UNLOGGED (sequence changes aren't WAL-logged), IF NOT EXISTS (no error if the sequence already exists), name (the sequence name), data_type (sequence's data type), increment (value added to the sequence), and minvalue/NO MINVALUE (minimum sequence value).