LJ Archive

Listing 2. Using the Serial Data Type

CREATE SEQUENCE people_id START 1;

CREATE TABLE People (
    person_id      INT4        NOT NULL
                               DEFAULT nextval('people_id'),
    name           VARCHAR(40) NOT NULL,
    address1       VARCHAR(30) NULL,
    address2       VARCHAR(30) NULL,
    email          VARCHAR(50) NOT NULL,
    city           VARCHAR(30) NULL,
    state          VARCHAR(2)  NULL,
    zip            VARCHAR(10) NULL,

    PRIMARY KEY(person_id),
    UNIQUE(name)
);
LJ Archive