## Sequences

A sequence is a database object that provides a series of integer values.

A sequence has a start value, an increment step value and a minimum value and a maximum value defined when it is created (by using the

`CREATE SEQUENCE`

statement).A sequence can be specified as having a certain data type which will determine the span of possible values for the sequence. The possible data types are

`SMALLINT`

,`INTEGER`

and`BIGINT`

.A sequence with

`CYCLE`

option will generate its series of values repeatedly.A sequence with

`NO CYCLE`

becomes exhausted when the end value has been used, and can not be used any more. (An exhausted sequence can be reset using the`ALTER SEQUENCE`

statement.)A sequence is created with an undefined value initially.

To generate the next value in the integer series of a sequence the

`NEXT VALUE`

function is used, see NEXT VALUE. When this expression is used for the first time after the sequence has been created, it establishes the initial value for the sequence. Subsequent uses will establish the next value in the series of integer values of the sequence as the current value of the sequence.It is also possible to get the current value of a sequence by using the

`CURRENT VALUE`

function, see CURRENT VALUE. This function can not be used until the initial value has been established for the sequence (by using`NEXT VALUE`

for the first time).If a sequence is dropped with the

`CASCADE`

option in effect, column defaults referencing the sequence will be removed, but the columns will still exist. Similarly domain defaults referencing the sequence will be removed, but the domains will still exist. Other objects referencing the sequence will be dropped.

Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |