1
ALTER SEQUENCE my_sequence
    INCREMENT BY '1000000000' - TO_NUMBER(SELECT last_number FROM all_sequences WHERE sequence_name='my_sequence');

有人可以向我解释为什么它会抛出“错误号码”吗?我试着到处放TO_NUMBER,我试过不加它,我试过不''加大号,我能想到的每一种组合,仍然是错误,对我来说根本没有任何意义。子查询有效,我检查了。

4

1 回答 1

3

改用 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;
于 2016-12-15T12:08:10.327 回答