类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
只有删除序列,在重建序列一种办法吗?
网友回答:
一句sql是不能够实现的,还不如直接drop再create呢?
比如一个sequence如下
-- Create sequence
create sequence SEQ_WXTHCOUNT
minvalue 1
maxvalue 99999999
start with 5523202
increment by 1
cache 20;
修改当前序列值为23的过程要经过一系列步骤,如下:
-- Modify the last number
alter sequence SEQ_WXTHCOUNT increment by -5523179 nocache;
select SEQ_WXTHCOUNT.nextval from dual;
alter sequence SEQ_WXTHCOUNT increment by 1 nocache;
declare
LastValue integer;
begin
loop
select SEQ_WXTHCOUNT.currval into LastValue from dual;
exit when LastValue >= 23 - 1;
select SEQ_WXTHCOUNT.nextval into LastValue from dual;
end loop;
end;
/
alter sequence SEQ_WXTHCOUNT increment by 1 cache 20;