如何把sequence的值重新置成1
现在一sequenceselect test.nextval from dual
45
我想把它置成1,即用上面的语句查出的结果是1,请问该如何做?谢谢! ALTER SEQUENCE serial RESTART WITH 1;
为了避免并发的事务从同一个序列获取数值的时候被阻塞住,ALTER SEQUENCE 操作从来不会回滚; 修改马上生效并且不能恢复。
ALTER SEQUENCE 将不会立即影响后端的 nextval 结果,除了当前的之外, 因为它又已经缓冲了的序列号。它们只有再使用光所有已经缓冲的数值之后才能意识到改变了的序列参数。当前后端将立即被影响。 plsql developer 中的方法
-- Modify the last number
alter sequence SEQ_TEST increment by -119 nocache;
select SEQ_TEST.nextval from dual;
alter sequence SEQ_TEST increment by 1 nocache;
declare
LastValue integer;
begin
loop
select SEQ_TEST.currval into LastValue from dual;
exit when LastValue >= 1 - 1;
select SEQ_TEST.nextval into LastValue from dual;
end loop;
end;
/
alter sequence SEQ_TEST increment by 1 cache 20;
页:
[1]