在建sequence时,有几个参数
Owner ,Minimum value,Maximum value,Initial value,Increment by ,Cache size,Cycle,Order
参数Cache size 到底起什么作用,将其设为10和20,对性能有多大
影响。
参数Cycle和Order具体又指什么,设为off,起什么作用。
另一个问题是,由于sequence直接建在数据库端,我在前端一直无法控制。例如,我前端用jsp,其中一个字段通过sequence产生,可是当用户在点击创建纪录时,又立即选择取消创建,而这时sequence已产生,如果下次创建时,该字段就不连续。
请教各位如何解决。
先谢了!
Owner ,Minimum value,Maximum value,Initial value,Increment by ,Cache size,Cycle,Order
参数Cache size 到底起什么作用,将其设为10和20,对性能有多大
影响。
参数Cycle和Order具体又指什么,设为off,起什么作用。
另一个问题是,由于sequence直接建在数据库端,我在前端一直无法控制。例如,我前端用jsp,其中一个字段通过sequence产生,可是当用户在点击创建纪录时,又立即选择取消创建,而这时sequence已产生,如果下次创建时,该字段就不连续。
请教各位如何解决。
先谢了!
1,11,21,31Cycle值是指当序列到最大值时。它的下一个值就到初始值了
例如定义最小值1,最大值10
那么1,2,3,...10,1,2,....一直循环下去
Cache当然就不是起这个作用了。还是感谢beckhambobo的回答。希望大家共同进步!
1,11,21,31
??
In the practical application,I specify the CACHE parameter 20.
I do not know how many the cache parameter should specify usually
and its influence .
In parallel mode,must I specify the ORDER option?
Another problem is that in my application, when customer insert a record, but he select giving up the new record at once before commit, unfortunately after he insert a record again ,there is a break in sequential numbering. please tell me how to solve the problem.
Thank you in advance.
DECLARE
TEMP_NO NUMBER;
BEGIN
LOCK TABLE PO_NUM IN EXCLUSIVE MODE NOWAIT;
SELECT MAX(PO_NUM)+1 INTO TEMP_NO FROM SALES ;
END;If the application requires numbers that are exactly in sequence (e.g. 1,2,3....) then the trigger shown above may be your only recourse. Note however that if a statement that references a sequence is rolled back (canceled) that sequence number is lost.
often used for artificial keys or to order rows that otherwise have no order.
Like constraints, sequences exist only in the data dictionary. Sequences can
be configured to increase or decrease without bound or to repeat (cycle)
upon reaching a bounding value. Sequences are created with the CREATE
SEQUENCE statement. Figure 6.5 shows the syntax of the CREATE SEQUENCE
statement.START WITH Defines the first number that the sequence will
generate. The default is one.INCREMENT BY Defines the increase or decrease for subsequently
generated numbers. To specify a decreasing
sequence, use a negative INCREMENT BY.MINVALUE The lowest number the sequence will generate.
This is the bounding value in a decreasing
sequence. The default MINVALUE is the keywordNOMINVALUE, which translates to 1 for an
increasing sequence and to –1026 for a decreasing
sequence.MAXVALUE The largest number that the sequence will
generate. This is the bounding value in the
default, increasing sequence. The default
MAXVALUE is the keyword NOMAXVALUE which
translates to 1027 for an increasing sequence and
to –1 for a decreasing sequence.CYCLE Configures the sequence to repeat numbers after
reaching the bounding value.NOCYCLE Configures the sequence to not repeat numbers
after reaching the bounding value. This is the
default. When you try to generate the
MAXVALUE+1, an exception will be raised.
CACHE Defines the size of the block of sequence
numbers held in memory. The default is 20.
NOCACHE Forces the data dictionary to be updated for each
sequence number generated, guaranteeing no
gaps in the generated numbers.