declare v_count number; begin select test_seq.nextval into v_count from dual; while v_count < 10000 loop select test_seq.nextval into v_count from dual; end loop; end
这是我测试用的代码,你改就可以了,将10000修改成你在的数字-1就行了我当时是想重用这个sequence的,将它设置为cycle,然后每天初始化一次,重置为1不过你的不用这么复杂,其实我感觉你应该直接用sequence就得了 insert into t1(f1,f2) values(test_seq.nextval, 'abcd') 这样不需要你去控制sequence的值了
可能是我没说明白,我最关心的是有没有这样的语句可以改变SEQUENCE的当前值,比如: SET test_seq.currentval=10000,如果有,我就不用select那么多次了,因为select慢
v_count number;
begin
select test_seq.nextval into v_count from dual;
while v_count < 10000 loop
select test_seq.nextval into v_count from dual;
end loop;
end
insert into t1(f1,f2) values(test_seq.nextval, 'abcd')
这样不需要你去控制sequence的值了
SET test_seq.currentval=10000,如果有,我就不用select那么多次了,因为select慢
select seq_name.nextval from dual; --得到想要值
alter SEQUENCE seq_name INCREMENT BY 1;