zoukankan      html  css  js  c++  java
  • 【MySQL】Event使用案例

    本文介绍一个实际的使用案例
    1、首先创建一个存储过程删除指定时间之前的数据。
    delimiter //
    CREATE PROCEDURE `proc_del_response_per_day`(in com_num int , in push_time datetime )
    begin
    declare curid bigint ;
    DECLARE rowid bigint ;
    declare no_more_departments int ;
    declare curs cursor for
    select response_per_day_id
    from
    response_per_day
    WHERE
    gmt_created < push_time ;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_departments = 1;
    SET no_more_departments=0;
    set rowid = 1 ;
    set autocommit = 0 ;
    open curs ;
    REPEAT
    fetch curs into curid ;
    delete from response_per_day where response_per_day_id = curid ;
    set rowid = rowid + 1 ;
    if rowid % com_num = 0
    then
    commit;
    end if ;
    UNTIL no_more_departments
    END REPEAT;
    commit ;
    close curs ;
    end;
    //
    delimiter ;

    2、创建一个定时器每个一个月调度一次
    create evnet e_call_proc_del_rpd
    on schedule every 1 month
    on completion preserve
    do call(200,now());

  • 相关阅读:
    K8S-安全机制
    K8S-Service
    K8S-Pod资源管理
    K8S-kubelet启动过程
    每日进度
    每日进度
    每日进度
    每日进度
    每日进度
    归纳及计划
  • 原文地址:https://www.cnblogs.com/OrcinusOrca/p/14812983.html
Copyright © 2011-2022 走看看