Defining an Identity Column
Defining an Identity Column
An identity column is a column that stores numbers that increment by one with each insertion. Identity columns are sometimes called autoincrement columns. Derby provides autoincrement as a built-in feature; see CREATE TABLE statement in the Derby Reference Manual.
Below is an example that shows how to use an identity column to create the MAP_ID column of the MAPS table in the toursDB database.
CREATE TABLE MAPS ( MAP_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), MAP_NAME VARCHAR(24) NOT NULL, REGION VARCHAR(26), AREA DECIMAL(8,4) NOT NULL, PHOTO_FORMAT VARCHAR(26) NOT NULL, PICTURE BLOB(102400), UNIQUE (MAP_ID, MAP_NAME) )
Previous Page
Next Page
Table of Contents
Index