OCP-1Z0-051-V9.02-43题

43. 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
Answer: A
 答案解析:
参考: http://blog.csdn.net/rlhua/article/details/12776779
实验验证:
1、首先创建这个序列
sh@TESTDB> CREATE SEQUENCE seq1
  2  START WITH 100
  3  INCREMENT BY 10
  4  MAXVALUE 200
  5  CYCLE
  6  NOCACHE;
 
Sequence created.
 2、查看值。
sh@TESTDB> select seq1.nextval from dual;
 
   NEXTVAL
----------
       100
 
sh@TESTDB> select seq1.currval from dual;
 
   CURRVAL
----------
       100
 3、因为该序列是循环的,到达最大值后从最小值MINVALUE开始循环,该序列因为省略MINVALUE省略,所以默认为NOMINVALUE最小值为 1,所有又从1开始。
sh@TESTDB> select seq1.nextval from dual;
 
   NEXTVAL
----------
       200
 
sh@TESTDB>
sh@TESTDB> select seq1.nextval from dual;
 
   NEXTVAL
----------
         1

 

 

 故答案选A

你可能感兴趣的:(OCP-1Z0-051-V9.02-43题)