首頁 > 資料庫 > mysql教程 > 批量操作初始化序列初始值

批量操作初始化序列初始值

WBOY
發布: 2016-06-07 14:57:50
原創
1456 人瀏覽過

批量初始化序列初始值 无 DECLARE TYPE tsi IS RECORD( t VARCHAR2(100) , s VARCHAR2(100), i varchar2(100)); tsiTemp tsi; maxId varchar2(20);BEGIN for tsiTemp in ( select 'T_xxxx_CONFIG'as t,'SEQ_xxxxx_ID' as s,'xxxx_ID' as i from dual union se

批量初始化序列初始值
DECLARE 
   TYPE tsi IS RECORD(
         t VARCHAR2(100) ,
         s VARCHAR2(100),
         i varchar2(100));
  tsiTemp tsi;
   maxId varchar2(20);
BEGIN
    for tsiTemp in (
      select  'T_xxxx_CONFIG'as t,'SEQ_xxxxx_ID' as s,'xxxx_ID' as i from dual 
      union
      select  'T_ttttt_INFO'as t,'SEQ_ttttt_ID' as s,'tttt_ID' as i from dual      
       union  
      select  'T_ddddd_LOG' as t,'SEQ_dddddd_ID' as s,'dddd_ID' as i from dual             
   )
    loop
    execute immediate  'select nvl(max('||tsiTemp.i||'+1),1) from '||tsiTemp.t into maxId;
   execute immediate 'drop sequence '||tsiTemp.s;
  execute immediate 'create sequence '||tsiTemp.s 
         || ' minvalue '||maxId
         || ' maxvalue 999999999999999999999999999 '
         || ' start with '||maxId
         || ' increment by 1'
         ||' cache 20'
         ||' order'; 
  end loop;
END;
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板