Home > Database > Mysql Tutorial > 批量操作初始化序列初始值

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

WBOY
Release: 2016-06-07 14:57:50
Original
1453 people have browsed it

批量初始化序列初始值 无 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;
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template