ALTER SEQUENCEは、シーケンス(順序)を変更するSQL文です。順序の初期値、増分値、最大値、最小値、および順序のサイクルを変更できます。
ALTER SEQUENCE sequence [START WITH start] [INCREMENT BY inc] [MINVALUE min] [MAXVALUE max] [CYCLE]
[RESTART]
SQL> ALTER SEQUENCE example START WITH 2;
SQL> SELECT example.NEXTVAL FROM DUAL;
NEXTVAL
-------
2
SQL> SELECT example.NEXTVAL FROM DUAL;
NEXTVAL
-------
3
SQL> ALTER SEQUENCE example INCREMENT BY 2;
SQL> SELECT example.NEXTVAL FROM DUAL;
NEXTVAL
-------
1
SQL> SELECT example.NEXTVAL FROM DUAL;
NEXTVAL
-------
3
SQL> ALTER SEQUENCE example MINVALUE 0;
SQL> ALTER SEQUENCE example MAXVALUE 999;
SQL> ALTER SEQUENCE example CYCLE;
SQL> ALTER SEQUENCE example RESTART;
シーケンス・ジェネレータの定義を変更する。
ALTER SEQUENCE [ IF EXISTS ] name
[ AS data_type ]
[ INCREMENT [ BY ] increment ]
[ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
[ START [ WITH ] start ]
[ RESTART [ [ WITH ] restart ] ]
[ CACHE cache ] [ [ NO ] CYCLE ]
[ OWNED BY { table_name.column_name | NONE } ]
ALTER SEQUENCE [ IF EXISTS ] name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER SEQUENCE [ IF EXISTS ] name RENAME TO new_name
ALTER SEQUENCE [ IF EXISTS ] name SET SCHEMA new_schema
既存のシーケンス・オブジェクトの引数を変更する。
ALTER SEQUENCE [schema_name. ] sequence_name
[ RESTART [ WITH constant ] ]
[ INCREMENT BY constant ]
[ { MINVALUE constant } | { NO MINVALUE } ]
[ { MAXVALUE constant } | { NO MAXVALUE } ]
[ CYCLE | { NO CYCLE } ]
[ { CACHE [ constant ] } | { NO CACHE } ]
[ ; ]