作者官方**:
建立儲存過程、mysql自身定時執行計畫
下面簡單刪除定時刪除過期資料場景/*
刪除儲存過程
*/dropprocedureifexistsp_dele_mp_addret; /*
刪除原有的定時任務
*/dropeventifexistsp_dele_mp_addret;
delimiter //
create event `p_dele_mp_addret`
on schedule
every 1 day starts '2018-12-26 07:10:28' ends '2021-03-26 07:17:43'
on completion not preserve
enable
comment ''
do begin
call p_dele_mp_addret();
end;//
-- 建立儲存過程
delimiter //
create procedure p_dele_mp_addret() ## 建立儲存過程
begin
delete from ts_clock_emp_address where invalid_date < date_format(date_sub(now(),interval 0 day),'%y-%m-%d');
delete from ts_clock_emp_grant where invalid_date < date_format(date_sub(now(),interval 0 day),'%y-%m-%d');
delete from tt_ecp_addres where id in(select ecpaddresid from tt_ecp_addres_detailed where invalid_date < date_format(date_sub(now(),interval 0 day),'%y-%m-%d'));
delete from tt_ecp_addres_detailed where invalid_date < date_format(date_sub(now(),interval 0 day),'%y-%m-%d');
end;//
作者官方**:
mysql建立儲存過程 定時呼叫
mysql怎麼讓乙個儲存過程定時執行 檢視event是否開啟 show variables like sche 將事件計畫開啟 set global event scheduler 1 關閉事件任務 alter event e test on completion preserve disable ...
MySQL 建立儲存過程及定時任務
建立定時任務名為 event csdn 2019 01 01 00 00 00 起每10s 執行 create event if not exists event csdn on schedule every 10 second starts timestamp 2019 01 01 00 00 0...
Mysql 建立儲存過程,建立定時器,使用詳解
1 儲存過程建立與使用 檢視當前庫中的儲存過程 select from mysql.proc where db 庫名 and type procedure 自定義界定符號的寫法示例 儲存過程存在則刪除 drop procedure if exists procedure name delimiter...