CREATE OR REPLACE SEQUENCE
Creates a sequence that can be used to generate primary key values that are unique across multiple tables, and for generating
default values for a table. An error is returned if you specify the name of a sequence that already exists for the current
Defines the amount the next sequence value is incremented from the last value assigned. The default is 1. Specify a negative
value to generate a descending sequence. An error is returned if the INCREMENT BY value is 0.
Defines the starting sequence value. If you do not specify a value for the START WITH clause, MINVALUE is used for ascending
sequences and MAXVALUE is used for descending sequences. An error is returned if the START WITH value is beyond the range
specified by MINVALUE or MAXVALUE.
Defines the smallest value generated by the sequence. The default is 1. An error is returned if MINVALUE is greater than
( 2^63-1) or less than -(2^63-1). An error is also returned if MINVALUE is greater than MAXVALUE.
Defines the largest value generated by the sequence. The default is 2^63-1. An error is returned if MAXVALUE is greater
than 2^63-1 or less than -(2^63-1).
Specifies the number of preallocated sequence values that are kept in memory for faster access. When the cache is exhausted,
the sequence cache is repopulated and a corresponding entry is written to the transaction log. At checkpoint time, the current
value of the cache is forwarded to the ISYSSEQUENCE system table. The default is 100.
Specifies whether values should continue to be generated after the maximum or minimum value is reached.
The default is NO CYCLE, which returns an error once the maximum or minimum value is reached.
A sequence is a database object that allows the automatic generation of numeric values. A sequence is not bound to a specific
or unique table column and is only accessible through the table column to which it is applied.
Sequences can generate values in one of the following ways:
Increment or decrement monotonically without bound
Increment or decrement monotonically to a user-defined limit and stop
Increment or decrement monotonically to a user-defined limit and cycle back to the beginning and start again
You control the behavior when the sequence runs out of values using the CYCLE clause.
If a sequence is increasing and it exceeds the MAXVALUE, MINVALUE is used as the next sequence value if CYCLE is specified.
If a sequence is decreasing and it falls below MINVALUE, MAXVALUE is used as the next sequence value if CYCLE is specified.
If CYCLE is not specified, an error is returned.
Sequence values cannot be used with views or materialized view definitions.