我正在使用 toad for oracle 11g,我尝试alter
使用sequence
UI(用户界面)。
我想改变currval
.
我阻止了这个错误:
ORA-04007: 不能使 MINVALUE 超过当前值
您不会currval
直接更改序列的伪列的值 - 每次引用nextval
序列的伪列时,其值都会更改。听起来更像是您想发出一条alter sequence
语句来更改其minvalue
参数。
如果序列的当前值小于minval
您尝试更改的值,则会引发错误。您至少有两种选择来完成它:
minvalue
使用参数的新值完全重新创建序列incremet by
值,生成下一个值,更改minval
参数,然后更改increment by
回值。这是一个例子:
create sequence seq
increment by 1
minvalue 1
sequence SEQ created.
-- trying to change minvalue
alter sequence seq
minvalue 5
SQL Error: ORA-04007: MINVALUE cannot be made to exceed the current value
select seq.nextval
from dual
NEXTVAL
------------
1
-- alter increment by
alter sequence seq
increment by 4
select seq.nextval
from dual
NEXTVAL
----------
5
-- altering minvalue
alter sequence seq
minvalue 5
sequence SEQ altered.
-- change increment by to 1 as it was before
alter sequence seq
increment by 1
sequence SEQ altered.