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语句