zoukankan      html  css  js  c++  java
  • 原!删除表存储过程

    -- 处理存储过程
    drop procedure if exists proc_drop_2017msg_tables;              -- 存储过程名称
    delimiter //
    create procedure proc_drop_2017msg_tables()                             -- 存储过程名称
      begin
    
        set @tab_year=17;                           -- 开始年份
        set @tab_month=09;                          -- 开始月份
        set @tab_day=20;                                    -- 开始日期
    
        while @tab_year<=17 do                      -- 结束年份
          while @tab_month<=12 do           -- 结束月份
            if (@tab_month=1 or @tab_month=3 or @tab_month=5 or @tab_month=7 or @tab_month=8 or @tab_month=10 or @tab_month=12) then
              set @days=31;
            elseif @tab_month=2 then
              if (@tab_year%400=0 or (@tab_year%4=0 and @tab_year%100<>0)) then
                set @days=29;
              else
                set @days=28;
              end if;
            else
              set @days=30;
            end if;
    
            while @tab_day<=@days do
              if @tab_month<10 then
                if @tab_day<10 then
                  set @table_name=CONCAT('open_messageinfo_20',@tab_year,'0',@tab_month,'0',@tab_day);      -- 表名
                else
                  set @table_name=CONCAT('open_messageinfo_20',@tab_year,'0',@tab_month,@tab_day);          -- 表名
                end if;
              else
                if @tab_day<10 then
                  set @table_name=CONCAT('open_messageinfo_20',@tab_year,@tab_month,'0',@tab_day);          -- 表名
                else
                  set @table_name=CONCAT('open_messageinfo_20',@tab_year,@tab_month,@tab_day);                      -- 表名
                end if;
              end if;
              set @alter_table_sql=concat('drop table ',@table_name,' ;');
              prepare statement from @alter_table_sql;
              execute statement;
              set @tab_day=@tab_day+1;
            end while;
            set @tab_month=@tab_month+1;
            set @tab_day=1;
          end while;
          set @tab_year=@tab_year+1;
          set @tab_month=1;
        end while;
      end
    //
    delimiter ;
    call proc_drop_2017msg_tables;                  -- 存储过程名称
    

      

  • 相关阅读:
    (二)php的常量和变量
    关于标签系统的一点想法。
    Linux运维工程师中级面试题
    Linux C 编程内存泄露检测工具(一):mtrace
    掌握sudo的使用
    Scala极速入门
    处理千万级以上的数据提高查询速度的方法
    linux svn服务器搭建、客户端操作、备份与恢复
    select/poll/epoll 对比
    汇编指令和标志寄存器
  • 原文地址:https://www.cnblogs.com/wuyun-blog/p/10640975.html
Copyright © 2011-2022 走看看