Oracle 动态设置SEQUENCE startwith 的值

Oracle 动态设置SEQUENCE startwith 的值

具体脚本如下:

DECLARE
s_ID NUMBER ;
BEGIN
s_ID :=1000;
SELECT MAX(schedule_id)+1 INTO s_ID  FROM tableName;
EXECUTE immediate 'CREATE SEQUENCE  SEQ_1  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH '||s_ID||' NOCACHE  NOORDER  NOCYCLE';
END;

如果SEQUENCE 已存在,可以在SQL中增加drop语句



posted @ 2015-12-07 17:32  雪来了  阅读(948)  评论(0编辑  收藏  举报