oracle重置序列从1开始
--创建存储过程
create or replace procedure seq_res_1 is v_sql varchar2(200); n number; begin select seq_name.CURRVAL into n from dual; v_sql:='alter sequence seq_name increment by -'||n||' minvalue 0'; execute immediate v_sql; select seq_name.nextval into n from dual; v_sql:='alter sequence seq_name increment by '||1||' minvalue 0'; execute immediate v_sql; end seq_res_1;
--执行存储过程,使序列初始值变为0,步长变为1
call seq_res_1();
3.通过Increment By来实现修改初始值。
例如:若序列名称是SEQ_TEST,初始值是13,而现在要设置初始值为1013,Increment By值为:1000(1013-13)
1) 执行:ALTER SEQUENCE SEQ_TEST INCREMENT BY 1000;
2) 执行:SELECT SEQ_TEST.NEXTVAL FROM DUAL;
3) 执行:ALTER SEQUENCE SEQ_TEST INCREMENT BY 1;
转发自:oracle重置序列从1开始