DB7.2以后才有sequence這個對象,創(chuàng)建的時候和oralce一樣。
CREATE SEQUENCE seq_name AS INT
START WITH 1
INCREMENT BY 1
MINVALUE 1
NO MAXVALUE
NO CYCLE
NO CACHE
ORDER
在使用的過程中有些不同
DB2中:nextval for sequencename ,prevval for sequencename
select nextval for seq_name from sysibm.sysdummy1;
select prevval for seq_name from sysibm.sysdummy1;
oracle中:sequencename.nextval,sequencename.currval
select seq_name.nextval from dual;
select seq_name.currval from dual;
sysibm.sysdummy1是DB2內存中的一個特殊的表。