geekofwar31
geekofwar31

Reputation: 21

Oracle SQL minvalue/maxvalue sequence syntax error

I am tasked with creating a sequence that starts with 5 and decrements by -3 until it hits 0. I cannot figure out how to get the syntax right on my statement and it is stumping me. I correctly made one where I used a fixed number instead of a noMaxValue, but I would like to figure it out using noMaxValue.

Working Query:

create sequence my_seq
increment by -3
start with 5
minvalue 0
maxvalue 9999999
nocycle;

My attempt at using noMaxValue:

create sequence my_seq
increment by -3
start with 5
minvalue 0
nomaxvalue
nocycle;

When I run this however I get an error saying "minvalue must be less than maxvalue." How can I go about writing this? Thanks!

Upvotes: 2

Views: 779

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270773

Things are just confused because your increment is negative. The following works:

create sequence my_seq increment by -3 start with 5
       maxvalue 5 nominvalue nocycle

Upvotes: 0

Related Questions