oracle 重置序列 nextval 为 1

前端之家收集整理的这篇文章主要介绍了oracle 重置序列 nextval 为 1前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
create or replace procedure p_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 maxvalue 9999 nocycle nocache'; --把 cycle 和 cache 关闭,否则会报错 execute immediate 'select ' || p_seq_name || '.nextval from dual' INTO l_val; execute immediate 'alter sequence ' || p_seq_name || ' increment by 1 minvalue 0 maxvalue 9999 cycle cache 20'; --重新打开 cycle 和 cache end; 原文链接:https://www.f2er.com/oracle/210527.html

猜你在找的Oracle相关文章