问题一:如何重置oracle序列
oracle序列创建以后,如果想重置序列从 0 开始,逐渐递增1,可以采用如下存储过程:
create or replace
procedure reset_seq( p_seq_name in varchar2 )
is
l_val number;
begin
execute immediate
‘select ‘ || p_seq_name || ‘.nextval from dual‘ INTO l_val;
execute immediate
‘alter sequence ‘ || p_seq_name || ‘ increment by -‘ || l_val ||
‘ minvalue 0‘;
execute immediate
‘select ‘ || p_seq_name || ‘.nextval from dual‘ INTO l_val;
execute immediate
‘alter sequence ‘ || p_seq_name || ‘ increment by 1 minvalue 0‘;
end;
/
执行传入序列名称即可:
execute reset_seq(‘test_seq’);
即可
参考: click here
原文地址:http://blog.csdn.net/topwqp/article/details/46623507