Sequences Wizard (DB2 LUW)

From DBArtisan
Jump to: navigation, search

Go Up to IBM DB2 for Linux, Unix, and Windows Object Wizards

A sequence allows the automatic generation of values, something well-suited to the generation of unique key values. Sequences are not tied to particular table columns. The Sequence Wizard lets you create a sequence without knowing the underlying commands. As you complete the Sequence Wizard, a CREATE SEQUENCE statement is generated from the information that you have supplied. When finished, you can compile the sequence on the target database or to write a script file containing the CREATE SEQUENCE statement.

The Sequence Wizard lets you:

  • Specify the name and owner of the sequence.
  • Set both the value of the sequence, and an interval and ranges for incrementing it.
  • Cache the sequence, cycle the sequence when it reaches its minimum or maximum values, and guarantee that sequence numbers are generated in the order of request.
Note: To create a sequence, it must belong to your schema or you need CREATE SEQUENCE privileges.

To Open the Sequence Wizard

  1. On the Navigator/Explorer, find the datasource where you want to add the new Sequence.
  2. Expand the Schema branch, right-click Sequences, and select New.

The table that follows describes what you may encounter as you complete the Sequence Wizard:

Required Information Description

Who owns the sequence?

You decide.

What is the sequence name?

Your choice.

What numeric datatype should the Sequence use?

Choose among BIGINT (big integer), decimal (choose width as well), integer, small integer.

What is the first sequence number to be generated?

Starting with 1 is the default.

What is the interval between sequence numbers?

Increment by 1 is the default.

What is the sequence’s minimum value?

Choose none or set a value

What is the sequence’s maximum value?

Choose none or set a value

Should DB2 preallocate sequence numbers and cache them for faster access?

Preallocating and storing values in the cache reduces synchronous I/O to the log when values are generated for the sequence. If Yes, give number of values No

Should the sequence continue to generate values after reaching either its maximum or minimum value?

Lets you make the sequence cycle and continue to generate numbers. Yes or No

Should the sequence numbers be generated in the order of request?

Select to generate sequence numbers in the order of request. The ORDER option is useful when you are using the sequence number as a timestamp. Yes or No