我正在使用toad for oracle 11g,我尝试使用UI(用户界面)alter
sequence
。
我想更改currval
。
我阻止了这个错误:
ORA-04007:MINVALUE不能超过当前值
答案 0 :(得分:4)
您不直接更改序列的伪列的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.