Sequences | Tarantool

Sequences

An introduction to sequences is in the Sequences section of the “Data model” chapter. Here are the details for each function and option.

All functions related to sequences require appropriate privileges.

Below is a list of all box.schema.sequence functions.

Name Use
box.schema.sequence.create() Create a new sequence generator
sequence_object:next() Generate and return the next value
sequence_object:alter() Change sequence options
sequence_object:reset() Reset sequence state
sequence_object:set() Set the new value
sequence_object:current() Return the last retrieved value
sequence_object:drop() Drop the sequence
specifying a sequence in create_index() Create an index with a sequence option

Example:

Here is an example showing all sequence options and operations:

s = box.schema.sequence.create(
               'S2',
               {start=100,
               min=100,
               max=200,
               cache=100000,
               cycle=false,
               step=100
               })
s:alter({step=6})
s:next()
s:reset()
s:set(150)
s:drop()
Found what you were looking for?
Feedback