日期:2014-05-16  浏览次数:20436 次

OCP考题解析_007: 序列
     sequence的设计可保唯一、但无法做到连续
     实例当了,sequence断号、事务回滚了,sequence断号、并发访问,sequence可能断号......
     
     调用seq_name.currval, 返回的是序列在此会话中的调用seq_name.currval之前的最后一次调用seq_name.nextval的返回值
     因此单独调用seq_name.currval时、必须确保在此之前该会话中有调用过seq_name.nextval(似乎有初始化作用)
     若seq_name.currval、seq_name.nextval 在同一个SQL语句中出现、则先执行seq_name.nextval,再执行seq_name.currval

     因此二者的返回值应是相等的


Q: 23 Which two statements about sequences are true? (Choose two.)

A. You use a NEXTVAL pseudo column to look at the next possible value that would be generated from a 
sequence, without actually retrieving the value. 

B. You use a CURRVAL pseudo column to look at the current value just generated from a sequence, without 
affecting the further values to be generated from the sequence. 

C. You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by actually 
retrieving the value from the sequence. 

D. You use a CURRVAL pseudo column to generate a value from a sequence that would be used for a 
specified database column. 

E. If a sequence starting from a value 100 and incremented by 1 is used by more than one application, then all 
of these applications could have a value of 105 assigned to their column whose value is being generated by the sequence. 

F. You use a REUSE clause when creating a sequence to restart the sequence once it generates the maximum 
value defined for the sequence. 

Answer: B, C