1.创建序列
CREATE SEQUENCE SEQ_XXXXX AS INT START WITH 1 INCREMENT BY 1 MINVALUE 1 NO MAXVALUE NO CYCLE NO CACHE ORDER;
红色为序列名;
2.查询序列当前值
select SEQ_XXXXX.prevval from sysibm.sysdummy1;
3.查询序列下一个值
select SEQ_XXXXX.nextval from sysibm.sysdummy1;
4.将下一个序列补足10位
select digits( SEQ_XXXXX.nextval) from sysibm.sysdummy1;
5.在XML中插入序列
INSERT INTO xx(表名)(xxx, test) VALUES (DIGITS(NEXTVAL FOR SEQ_XXXXX), 'test');
6.删除序列
DROP SEQUENCE SEQ_XXXXX;