sequences的用法

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 guost 的 blog

create sequence supplier_seq
    minvalue 1
    maxvalue 999999999999999999999999999
    start with  1
    increment by  1
    cache 20;

this would create a sequence object called supplier_seq.  the first sequence number that it would use is 1 and each subsequent number would increment by 1 (ie: 2,3,4,...}.  it will cache up to 20 values for performance.

now that you've created a sequence object to simulate an autonumber field, we'll cover how to retrieve a value from this sequence object.  to retrieve the next value in the sequence order, you need to use nextval.

for example:

supplier_seq.nextval

this would retrieve the next value from supplier_seq.  the nextval statement needs to be used in an sql statement.  for example:

insert into suppliers
(supplier_id, supplier_name)
values
(supplier_seq.nextval, 'kraft foods');

本文关键:sequences的用法
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top