oracle 序列重設,oracle序列

來源:互聯網
上載者:User

oracle 序列重設,oracle序列

問題一:如何重設oracle序列
oracle序列建立以後,如果想重設序列從 0 開始,逐漸遞增1,可以採用如下預存程序:

create or replaceprocedure 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

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.