Online Documentation for SQL Manager for DB2
Sequences
A Sequence is a database object from which multiple users can generate unique integers. You can use sequences to automatically generate primary key values. When a sequence number is generated, the sequence is incremented, independent of the transaction being committed or rolled back.
If two users concurrently increment the same sequence, then the sequence numbers each user acquires may have gaps, because sequence numbers are being generated by the other user. One user can never acquire the sequence number generated by another user. After a sequence value is generated by one user, that user can continue to access that value regardless of whether the sequence is incremented by another user.
To create a new sequence:
- select the Database | New Object... main menu item;
- select Sequence in the Create New Object dialog;
- edit sequence properties using the appropriate tabs of Sequence Editor.
Hint: To create a new sequence, you can also right-click the Sequences node of the DB Explorer tree and select the New Sequence... context menu item.
To create a new sequence with the same properties as one of existing sequences has:
- select the Database | Duplicate Object... main menu item;
- follow the instructions of Duplicate Object Wizard.
Alternatively, you can right-click a sequence in the DB Explorer tree and select the Duplicate Sequence <sequence_name>... context menu item.
Duplicate Object Wizard allows you to select the database to create a new sequence in, and to edit the result SQL statement for creating the sequence.
To edit an existing sequence:
- select the sequence for editing in the DB Explorer tree (type the first letters of the sequence name for quick search);
- right-click the object and select the Edit Sequence <sequence_name>... context menu item, or simply double-click the sequence;
- edit sequence definition using the appropriate tabs of Sequence Editor.
To drop a sequence:
- select the sequence to drop in the DB Explorer tree;
- right-click the object and select the Drop Sequence <sequence_name>... context menu item;
- confirm dropping in the dialog window.
Note: If more convenient, you can also use the following shortcuts:
Ctrl+N to create a new sequence;
Ctrl+O to edit the selected sequence;
Shift+Del to drop the object from the database.