ORA-08004: sequence nextval exceeds maxvalue cannot be instantiated

Source: Internet
Author: User

If no cyclic cycle is set for sequence, a ORA-08004 error occurs when the maximum value of sequence is exceeded.

SQL> Create sequence test_seq_no_cycle
2 minvalue 1
3 maxvalue 200
4 start with 100
5 increment by 50
6 nocache;

Sequence created

SQL> select test_seq_no_cycle.nextval from dual;

Nextval
----------
100

SQL> select test_seq_no_cycle.nextval from dual;

Nextval
----------
150

SQL> select test_seq_no_cycle.nextval from dual;

Nextval
----------
200

SQL> select test_seq_no_cycle.nextval from dual;

Select test_seq_no_cycle.nextval from dual

ORA-08004: sequence test_seq_no_cycle.nextval exceeds maxvalue cannot be instantiated

 

 

SQL> Create sequence test_seq
2 minvalue 1
3 maxvalue 200
4 start with 100
5 increment by 50
6 nocache
7 cycle;

Sequence created

 

SQL> select test_seq.nextval from dual;

Nextval
----------
100

SQL> select test_seq.nextval from dual;

Nextval
----------
150

SQL> select test_seq.nextval from dual;

Nextval
----------
200

 

After the maximum value of sequenc is reached, if cycle is set, the initial value of sequence starts from minvalue, instead of the set start with value.

SQL> select test_seq.nextval from dual;

Nextval
----------
1

SQL> select test_seq.nextval from dual;

Nextval
----------
51

SQL> select test_seq.nextval from dual;

Nextval
----------
101

SQL> select test_seq.nextval from dual;

Nextval
----------
151

SQL> select test_seq.nextval from dual;

Nextval
----------
1

SQL> select test_seq.nextval from dual;

Nextval
----------
51

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.