Sequences in Netezza

What is a sequence?

A sequence is a named object in a database that can be used to generate unique numbers.

A sequence may be byteint, smallint, integer, bigint. You can use sequence values wherever you would use numeric values. You can create, alter, and drop named sequences.

****

Syntax:

CREATE SEQUENCE sequence_name AS data_type   [<options>];

where the options are the following:

> START WITH start_value

> INCREMENT BY increment_value

> NO MINVALUE | MINVALUE minimum_value

> NO MAXVALUE | MAXVALUE maximum_value

> NO CYCLE | CYCLE

****

Sequences do not support cross database access; you cannot obtain a sequence value from a sequence defined in a different database.

Default MINVALUE is 1

Default MAXVALUE is the max value possible in the datatype.

INCREMENT BY can take both positive and negative values

By default, sequences do not cycle.

Sequences have gaps because IBM Netezza caches sequence values on the host and SPUs for efficient operation.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: