CREATE SEQUENCE
Defines a new named sequence number generator object. Like AUTO_INCREMENT and IDENTITY sequences, named sequences let you set the default values of primary key columns. Sequences guarantee uniqueness, and avoid constraint enforcement problems and overhead.
For more information about sequence types and their usage, see Sequences.
Syntax
CREATE SEQUENCE [ IF NOT EXISTS ] [[database.]schema.]sequence [ INCREMENT [ BY ] integer ] [ MINVALUE integer | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] [ START [ WITH ] integer ] [ CACHE integer | NO CACHE ] [ CYCLE | NO CYCLE ]
Parameters
IF NOT EXISTS
|
Specifies to generate an informational message if an object already exists under the specified name. If you omit this option and the object exists, Vertica generates a The For related information, see |
[database.]schema
|
Specifies a schema, by default myschema.thisDbObject If you specify a database, it must be the current database. |
sequence |
Identifies the sequence to create, where sequence conforms to conventions described in Identifiers. It must also be unique among all names of sequences, tables, projections, views, and models within the same schema. |
INCREMENT [BY] integer
|
A positive or negative integer that specifies how much to increment or decrement the sequence on each call to Setting this parameter to integer guarantees that column values always increment by at least integer. However, column values can sometimes increment by more than integer unless you also set the |
MINVALUE integer
NO MINVALUE (default)
|
Determines the minimum value a sequence can generate. If you omit this clause or specify NO MINVALUE, default values are used: 1 and ‑263‑1 for ascending and descending sequences, respectively. |
MAXVALUE integer
NO MAXVALUE (default)
|
Determines the maximum value for the sequence. If you omit this clause or specify NO MAXVALUE, default values are used: 263‑1 and ‑1 for ascending and descending sequences, respectively. |
START [WITH] integer |
Sets the sequence start value to integer. The next call to |
CACHE integerNO CACHE |
Specifies whether to cache unique sequence numbers on each node for faster access.
If you omit this clause, the sequence cache is set to 250,000. For details, see Sequence Caching in the Administrator's Guide. |
CYCLE
NO CYCLE (default)
|
Specifies whether the sequence can wrap when its minimum or maximum values are reached:
|
Privileges
Non-superusers: CREATE privilege on the schema
Examples
See Creating and Using Named Sequences.