首页 > 代码库 > Oracle序列归0的2种方法

Oracle序列归0的2种方法

1.用存储过程让myseq序列归0

declaren number(10);tsql varchar2(100);beginselect MYSEQ.nextval into n from dual;n:=-(n-1);tsql:=‘alter sequence MYSEQ increment by‘|| n;execute immediate tsql;select MYSEQ.nextval into n from dual;tsql:=‘alter sequence MYSEQ increment by 1‘;execute immediate tsql;end;/ 

2.重建序列

drop sequence seq_name;create sequence seq_namestart with 0minvalue 0

 

Oracle序列归0的2种方法