关于sequence的问题.currval和nextval

[复制链接]
查看11 | 回复9 | 2005-10-30 17:05:33 | 显示全部楼层 |阅读模式
you create a sequence with the following statement:
create sequence my_seq
start with 394
increment by 12
nominvalue
nomaxvalue
nocache
nocycle
Three user have alredy issued SQL statement to obtain NEXTVAL,and four more have issued SQL statements to obtain CURRVAL.if you issue a SQL statement to obtain the NEXTVAL ,what will oracle return?
A.406. B.418,C.430,D.442
书上给的答案是B.418
我算得是C.430
为什么?
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
在SEQUENCE有效的情况下,共计选择了4次NEXTVAL 所以应该是394+48=442,大家说对妈?
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
好像应该是430
因为第一次取nextval 返回的应该是394,然后再取三次nextval应当是返回430
其中取currval似乎不会影响其值
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
should be 418,
1st time: 394
2nd time: 394 + 12
3rd time 394+12+12 = 418
Note : Only 3 user refer to nextval
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
the answer is 430.
SQL> create sequence my_seq
2start with 394
3increment by 12
4nominvalue
5nomaxvalue
6nocache
7nocycle ;
SQL> select my_seq.nextval from dual;
NEXTVAL
----------
394
SQL> select my_seq.nextval from dual;
NEXTVAL
----------
406
SQL> select my_seq.nextval from dual;
NEXTVAL
----------
418
SQL> select MY_SEQ.CURRVAL from dual;
CURRVAL
----------
418
SQL> select my_seq.nextval from dual;
NEXTVAL
----------
430
勤动手,多实践!
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
那就是答案错了我对那本原版书的好印像完没了
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
序列没有初始化是不能用的.呵呵
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
原版书都出错,真伤心
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
应该是430=394+3*12
回复

使用道具 举报

千问 | 2005-10-30 17:05:33 | 显示全部楼层
394+12*4=442
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行