赞
踩
设置序列值的方法一般有如下两种,
1.删除重建
- drop sequence seq_t;
- create sequence seq_t;
- increment by 1
- start with 1//任何值
- maxvalue 99999999999999;
2.修改步长再改回去
- select seq_t.nextval from dual;//先看下当前值,比如a
- alter sequence seq_t increment by b; //b为预想的值和a的差
- select seq_t.nextval from dual; //达到预想值
- alter sequence seq_t increment by 1;//再改回步长为1
3.将序列值设置为id当前最大值
- declare
- Max_Id NUMBER(10);
- Current_Value NUMBER(10);
- BEGIN
- SELECT max(ID) INTO Max_Id FROM "LANGUAGE";
- loop
- SELECT LANGUAGE_SEQ.NEXTVAL INTO Current_Value FROM dual;
- exit when Current_Value >= Max_Id ; -- 终止条件
- end loop;
- end;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。