oracle 序列重置
问题一:怎样重置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