Using a Named Sequence with an AUTO_INCREMENT or IDENTITY Column
A table can contain only one AUTO_INCREMENT
or IDENTITY
column. A table with an AUTO_INCREMENT
or IDENTITY
column can also contain a named sequence. In the following example, table test2
contains a named sequence (my_seq
), and an auto_increment
value for the column last
):
VMart=> CREATE TABLE test2 (id INTEGER NOT NULL UNIQUE, middle INTEGER DEFAULT NEXTVAL('my_seq'), next INT, last AUTO_INCREMENT); CREATE TABLE