Skip to content

Sequence Operations

Sequence Options

The createSequence and alterSequence methods both take an options argument that specifies parameters of a sequence.

OptionTypeDescription
typestringtype of the sequence
incrementnumbersets first value of sequence
minvaluenumber or null or falsesets minimum value of sequence or NO MINVALUE (if value is false or null)
maxvaluenumber or null or falsesets maximum value of sequence or NO MAXVALUE (if value is false or null)
startnumbersets first value of sequence
cachenumbersets how many sequence numbers should be pre-allocated
cyclebooleanadds CYCLE or NO CYCLE clause if option is present
ownerstring or null or falsesets owner of sequence or no owner (if value is false or null)

Operation: createSequence

pgm.createSequence( sequence_name, options )

IMPORTANT

Create a new sequence - postgres docs

Arguments

NameTypeDescription
sequence_namestringname of the new sequence
optionsobjectCheck below for available options

Options

OptionTypeDescription
temporarybooleanadds TEMPORARY clause
ifNotExistsbooleanadds IF NOT EXISTS clause
sequence optionsobjectsee sequence options section

Reverse Operation: dropSequence

pgm.dropSequence( sequence_name, drop_options )

IMPORTANT

Drop a sequence - postgres docs

Arguments

NameTypeDescription
sequence_namestringname of the sequence to drop
drop_optionsobjectCheck below for available options

Options

OptionTypeDescription
ifExistsbooleandrops sequence only if it exists
cascadebooleandrops also dependent objects

Operation: alterSequence

pgm.alterSequence( sequence_name, options )

IMPORTANT

Alter a sequence - postgres docs

Arguments

NameTypeDescription
sequence_namestringname of the sequence to alter
optionsobjectCheck below for available options

Options

OptionTypeDescription
restartnumber or truesets first value of sequence or using start value (on true value)
sequence optionsobjectsee sequence options section

Reverse Operation: renameSequence

pgm.renameSequence( old_sequence_name, new_sequence_name )

IMPORTANT

Rename a sequence - postgres docs

Arguments

NameTypeDescription
old_sequence_namestringold Name of the sequence
new_sequence_namestringnew Name of the sequence