Oracle 在一个序列上更改 increment_by
Oracle change increment_by on a sequence
ALTER SEQUENCE my_sequence
INCREMENT BY '1000000000' - TO_NUMBER(SELECT last_number FROM all_sequences WHERE sequence_name='my_sequence');
有人可以向我解释为什么会抛出 'Incorrect number' 吗?我试过把 TO_NUMBER
放在任何地方,我试过没有它,我试过没有 ''
大数字,我能想到的每一种组合,仍然错误,对我来说根本没有任何意义.子查询有效,我检查过。
改用pl/sql块:
DECLARE
INC NUMBER;
BEGIN
SELECT 1000000000 - LAST_NUMBER
INTO INC
FROM USER_SEQUENCES
WHERE SEQUENCE_NAME='my_sequence';
EXECUTE IMMEDIATE 'ALTER SEQUENCE my_sequence INCREMENT BY '||INC;
END;
ALTER SEQUENCE my_sequence
INCREMENT BY '1000000000' - TO_NUMBER(SELECT last_number FROM all_sequences WHERE sequence_name='my_sequence');
有人可以向我解释为什么会抛出 'Incorrect number' 吗?我试过把 TO_NUMBER
放在任何地方,我试过没有它,我试过没有 ''
大数字,我能想到的每一种组合,仍然错误,对我来说根本没有任何意义.子查询有效,我检查过。
改用pl/sql块:
DECLARE
INC NUMBER;
BEGIN
SELECT 1000000000 - LAST_NUMBER
INTO INC
FROM USER_SEQUENCES
WHERE SEQUENCE_NAME='my_sequence';
EXECUTE IMMEDIATE 'ALTER SEQUENCE my_sequence INCREMENT BY '||INC;
END;