(学) 如何将 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; 

 

From http://www.google.com.hk/search?hl=zh-CN&newwindow=1&safe=strict&client=aff-cs-360se&hs=YSd&q=oracle+SEQUENCE+reset&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&aqi=&aql=&oq=

 

posted @ 2011-04-26 15:34  禹过天晴  阅读(1912)  评论(0编辑  收藏  举报