Identity Column Support

Many applications require the use of numbers to track invoices, customers, and other objects that get incremented by one whenever a new item is created. In database applications, usually a single column within a table represents a unique identifier for that row and that identifier gets sequentially updated as new records are added. DB2 has two different techniques for updating values in a table. These techniques are discussed in the sections that follow.

Identity Column

DB2 can auto-increment values in a table through the use of identity columns during record insertion. The following example demonstrates a table definition with the EMP_NO column automatically generated:

							CREATE TABLE EMPLOYEE (
							 EMPNO INT GENERATED ALWAYS ...

Get DB2® Version 8: The Official Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.