DB2 Version 9.7 for Linux, UNIX, and Windows

Sequences

A sequence is a database object that allows the automatic generation of values, such as cheque numbers. Sequences are ideally suited to the task of generating unique key values. Applications can use sequences to avoid possible concurrency and performance problems resulting from column values used to track numbers. The advantage that sequences have over numbers created outside the database is that the database server keeps track of the numbers generated. A crash and restart will not cause duplicate numbers from being generated.

The sequence numbers generated have the following properties:

There are two expressions that can used with sequences:

For complete details and examples of these expressions, see Sequence reference.