----------  Create, Alter or Drop Sequence  ----------

The "create sequence" command creates a sequence in the database.  

Syntax:

 create sequence SEQUENCE  [type | 32 |] 
                                 | 64 |
                           [seqid SEQID]
                           startvalue STARTVALUE
                           [endvalue ENDVALUE] 
                           [increment by INCREMENT]
                           [cache CACHE];

type 32 indicates to create a 32-bit sequence, type 64 indicates to create
a 64-bit sequence. Default is type 32.

SEQID is a positive 4-byte integer and must be unique to other sequences.
If it is not specified, a unique id will be automatically generated.

STARTVALUE is a 4-byte integer for 32-bit sequence or a 8-byte integer for
64-bit sequence which specifies the first sequence number to be generated.

ENDVALUE is a 4-byte integer for 32-bit sequence or a 8-byte integer for
64-bit sequence which specifies the last sequence number to be generated. 
It's value must be greater than STARTVALUE if INCREMENT is positive, otherwise
must be less than STARTVALUE. If endvalue is not specified, it's value is
2147483647 for 32-bit sequence or 9223372036854775807 for 64-bit sequence 
while INCREMENT is positive, or -2147483647  for 32-bit sequence or 
-9223372036854775807 for 64-bit sequence while INCREMENT is negative.

INCREMENT is a 4-byte integer for 32-bit sequence or a 8-byte integer for
64-bit sequence which specifies the interval between sequence numbers. If it is
omitted, the interval defaults to 1 when ENDVALUE is greater than STARTVALUE,
otherwise -1.

CACHE is a positive 4-byte integer which specifies how many values of the
sequence pre-allocates and keeps in memory for fast access. If it is not 
specified, it is given to 1.

To alter a sequence, the "alter sequence" command is used:

Syntax:

 alter sequence SEQUENCE [startvalue STARTVALUE]
                         [endvalue ENDVALUE]  
                         [increment by INCREMENT]
                         [cache CACHE]
                         [nextvalue { NEXTVALUE | refer TABLE (ATTR_NAME)}];

If nextvalue clause is specified to "refer TABLE (ATTR_NAME)", its value will
be changed to the max() of attribute ATTR_NAME in table TABLE plus INCREMENT
if INCREMENT is positive, otherwise the min() of attribute ATTR_NAME in 
table TABLE plus INCREMENT. The data type of attribute ATTR_NAME must be 
sequence (SEQUENCE).

To remove a sequence from the database, the
"drop sequence" command is used.

Syntax:

     drop sequence SEQUENCE;


For further information on display sequence information, enter:

                help display;
