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. This statement applies to SAP Sybase IQ catalog store tables only.
CREATE [ OR REPLACE ] SEQUENCE [ owner.] sequence-name [ INCREMENT BY signed-integer ] [ START WITH signed-integer ] [ MINVALUE signed-integer | NO MINVALUE ] [ MAXVALUE signed-integer | NO MAXVALUE ] [ CACHE integer | NO CACHE ] [ CYCLE | NO CYCLE ]
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:
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.
You must have the CREATE ANY SEQUENCE or CREATE ANY OBJECT system privilege to create sequences.
None
In addition, the following are vendor extensions:
The following example creates a sequence named Test that starts at 4, increments by 2, does not cycle, and caches 15 values at a time:
CREATE SEQUENCE Test START WITH 4 INCREMENT BY 2 NO MAXVALUE NO CYCLE CACHE 15;