Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 2.51 KB

sequences.md

File metadata and controls

65 lines (42 loc) · 2.51 KB

Sequence Operations

Sequence Options

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

  • type [string] - type of the sequence
  • increment [number] - sets first value of sequence
  • minvalue [number or boolean] - sets minimum value of sequence or NO MINVALUE (if value is false or null)
  • maxvalue [number or boolean] - sets maximum value of sequencee or NO MAXVALUE (if value is false or null)
  • start [number] - sets first value of sequence
  • cache [number] - sets how many sequence numbers should be preallocated
  • cycle [boolean] - adds CYCLE or NO CYCLE clause if option is present
  • owner [string or boolean] - sets owner of sequence or no owner (if value is false or null)

pgm.createSequence( sequence_name, options )

Create a new sequence - postgres docs

Arguments:

  • sequence_name [Name] - name of the new sequence
  • options [object] - options:
    • sequence options -- see sequence options section
    • temporary [boolean] - adds TEMPORARY clause
    • ifNotExists [boolean] - adds IF NOT EXISTS clause

Reverse Operation: dropSequence


pgm.dropSequence( sequence_name, drop_options )

Drop a sequence - postgres docs

Arguments:

  • sequence_name [Name] - name of the the sequence to drop
  • drop_options [object] - options:
    • ifExists [boolean] - drops sequence only if it exists
    • cascade [boolean] - drops also dependent objects

pgm.alterSequence( sequence_name, options )

Alter a sequence - postgres docs

Arguments:

  • sequence_name [Name] - name of the new sequence
  • options [object] - options:
    • sequence options -- see sequence options section
    • restart [number or boolean] - sets first value of sequence or using start value (on true value)

pgm.renameSequence( old_sequence_name, new_sequence_name )

Rename a sequence - postgres docs

Arguments:

  • old_sequence_name [Name] - old name of the sequence
  • new_sequence_name [Name] - new name of the sequence