What is displayed by the SELECT statement?

Evaluate the following CREATE SEQUENCE statement:
CREATE SEQUENCE seq1
START WITH 100
INCREMENT BY 10
MAXVALUE 200
CYCLE
NOCACHE;
The SEQ1 sequence has generated numbers up to the maximum limit of 200. You issue the following SQL
statement:
SELECT seq1.nextval FROM dual;
What is displayed by the SELECT statement?

A.
1

B.
10

C.
100

D.
an error

Discussion

8 Responses to “What is displayed by the SELECT statement?”

  1. Sue says:

    I tried the create and select queries on real database. I got “100″, not “1″.

    SQL> CREATE SEQUENCE seq1
    START WITH 100
    INCREMENT BY 10
    MAXVALUE 200
    CYCLE
    NOCACHE;
    2 3 4 5 6
    Sequence created.

    SQL> SELECT seq1.nextval FROM dual;

    NEXTVAL
    ———-
    100

  2. anitha says:

    ans is 1. Once the max value 200 is reached then when u execute
    SQL>SELECT seq1.nextval FROM dual;

    it will return 1
    try

  3. guest says:

    its just Present Perfect… ->The SEQ1 sequence has generated numbers up to…

    ‘cos it is 1. We have already had max value 200, so SELECT seq1.nextval FROM dual; -> SELECT statement will display 1.

    L2EngGrammar ;)

  4. banu says:

    The minvalue by default is set as 1.
    You can also give the minvalue explicitly.

  5. Just to add extra information…
    if we take off the CYCLE, it will generate an error after 200.

  6. Ritam Tiwari says:

    output will be like this if we try to calculate nextvalue:

    100,110,120,130,140,150,160,170,180,190,200,1,11,21,31,41,51..,191,1,11,…..

  7. Ritam Tiwari says:

    Thanks ERIC…

Leave a Reply

Recent comments