# 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 Java DB 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)
    )

Parent topic: SQL tips
Related concepts
Retrieving the database connection URL
Supplying a parameter only once
Using third-party tools
Tricks of the VALUES clause