日期:2014-05-16  浏览次数:20736 次

使用db2 sequence
原文http://blog.csdn.net/vicky8081/archive/2005/11/28/538508.aspx


创建sequence,产生id
CREATE SEQUENCE xixi.id_log
       AS bigint
       START WITH 1
       INCREMENT BY 1
       NO MAXVALUE
       CYCLE
       NO CACHE;

具体差数说明见ibm说明(http://publib.boulder.ibm.com/infocenter/db2help/topic /com.ibm.db2.udb.doc/admin/r0004201.htm?resultof=%22%73%65%71%75%65%6e %63%65%22%20)

--查询之前的id
VALUES PREVVAL FOR xixi.id_log;

--产生id
VALUES NEXTVAL FOR xixi.id_log;

--插入记录

insert into xixi.id_log(id) values
( NEXTVAL FOR xixi.id_log)

--删除sequence
DROP SEQUENCE  userid.ID_PDALOG restrict


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/vicky8081/archive/2005/11/28/538508.aspx