oracle 更改序列的初始值____oracle

來源:互聯網
上載者:User
 declare v_in varchar2(1024); v_start int;v_end int ; v_table varchar2(200);v_seq varchar2(200);v_table_seq varchar2(100);    begin      v_table:='jx_khfa';--表名      v_seq:='seq_jx_khfa';--序列名      v_table_seq:='id';--表欄位對應序列     v_in:= 'select max('||v_table_seq||') from '||v_table;--查詢表中最大值    execute immediate v_in into v_start;     v_in:= 'select '||v_seq||'.nextval from dual ';--查詢下一個序列值    execute immediate v_in into v_end;      v_in:= 'ALTER SEQUENCE '||v_seq||' INCREMENT BY '||to_char(v_start-v_end+1);--更改步長     execute immediate v_in;    execute immediate 'select '||v_seq||'.nextval from dual ' into v_end;--執行一次序列    execute immediate 'ALTER SEQUENCE '||v_seq||' INCREMENT BY 1';--改回步長      end;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.