January 2005
Beginner to intermediate
928 pages
22h 14m
English
A sequence is a database object that allows automatic generation of values. Unlike identity columns, this object does not depend on any table—the same sequence object can be used across the database.
To create a sequence, use the CREATE SEQUENCE statement as demonstrated here.
CREATE SEQUENCE myseq AS INTEGER START WITH 1 INCREMENT BY 1 NO MAXVALUE NO CYCLE CACHE 5
This statement creates the sequence myseq, which is of type INTEGER. The sequence starts with a value of 1 and then increases by 1 each time it's invoked for the next value.
The NO MAXVALUE clause indicates there is no explicit maximum value in which the sequence will stop; therefore, it will be bound by the limit of the data type, in this case, INTEGER.
The NO CYCLE ...
Read now
Unlock full access