(学) 如何将 Oracle 序列 重置 清零 How to reset an Oracle sequence
背景:需求决定目标
解决办法:
1、Baidu ,关键字: Oracle、序列、重置、清零
结果: 大家都在提问、质疑,没有答案。
2、Google,Key word: oracle 、sequence、reset
Result:
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;