1、创建索引的时候,最好不要加双引号,比如:

db2 ==> CREATE SEQUENCE "seq_test" ...

应该改为:

db2 ==> CREATE SEQUENCE seq_test ...

加了双引号,表示大小写敏感,如果你使用以下语句去查找序列的话,则会报错:

db2 ==> select (nextval for seq_test) from sysibm.sysdummy1;

SQL0204N  "XXX.SEQ_TEST" is an undefined name.  SQLSTATE=42704

2、select nextval for seq_test from sysibm.syssequences 会列出CACHE缓存中的所有值,获取一个值应该使用:

select (nextval for seq_test) from sysibm.sysdummy1;

或者

select (next value for seq_test) from sysibm.sysdummy1;

3、序列设置开始值

 DB2:ALTER SEQUENCE 序列名  RESTART WITH 下一值

4、修改
 修改最大值:   ALTER SEQUENCE <sequence_name> MAX VALUE <numeric-constant> | NO MAXVALUE
 修改最小值:   ALTER SEQUENCE <sequence_name> MIN VALUE <numeric-constant> | NO MINVALUE (此值需要比当前值小)
 修改步长:    ALTER SEQUENCE <sequence_name> INCREMENT BY <numeric-constant>;
 修改CACHE值: ALTER SEQUENCE <sequence_name> CACHE <numeric-constant> | NO CACHE
 修改循环属性: ALTER SEQUENCE <sequence_name> <CYCLE | NO CYCLE>
 修改排序属性:ALTER SEQUENCE <sequence_name> <ORDER | NO ORDER>
 从新计数:    ALTER SEQUENCE <sequence_name> RESTART | RESTART WITH <numeric-constant>

5、DROP:    DROP SEQUENCE <sequence_name>;