A sequence can be used to provide the default value for a table column or a domain, etc.
A sequence returns a series of integer values which is defined by a start value, a minimum value, a maximum value, an increment value, and whether the sequence is to be cyclic or not.
A sequence that has been initialized has a current value, which is returned from the function
CURRENT VALUE. The function
NEXT VALUEis used to initialize a sequence and to subsequently advance the current value of the sequence through its defined series of values.
A no cycle sequence will never return the same value twice.
Examples of Sequences
Create a sequence that returns odd numbers:CREATE SEQUENCE seq_1 START WITH 1 INCREMENT BY 2 IN userdb;
Create a sequence that defines the following series of values: 1, 4, 7, 10:CREATE SEQUENCE seq_2 START WITH 1 INCREMENT 3 MAXVALUE 10 NO CYCLE IN DATABANK userdb;
Create a table that uses a sequence to set a column default value:CREATE TABLE objinfo (objid INTEGER DEFAULT NEXT VALUE FOR obj_seq, description NCHAR VARYING(1000));
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40