Search code examples
sqloracledatabase-sequence

Create sequence with specific set of values in oracle


I would like to create a sequence in oracle that will consists of two values(1, -1).

Sequence will be 1,-1,1,-1,1,-1

Is it possible to create this type of sequence in oracle that will alternate between this two values only?

Is this possible using standard Create sequence syntax in oracle?


Solution

  • Yes, this is possible:

    create sequence seq_alternate 
       minvalue -1
       maxvalue 1
       start with 1
       increment by 2
       nocache
       cycle;