[MySQL] event_scheduler (JOB) 設定方法

inno
2023-10-23 17:00 251 0
[MySQL] event_scheduler (JOB) 設定方法

event_schedulerが開始されているか確認。

use analysis;

show variables like '%event%';

実行結果
aurora_binlog_reserved_event_bytes 1024
binlog_row_event_max_size 8192
binlog_rows_query_log_events OFF
event_scheduler ON
log_bin_use_v1_row_events OFF
performance_schema_events_stages_history_long_size 0
performance_schema_events_stages_history_size 0
performance_schema_events_statements_history_long_size 0
performance_schema_events_statements_history_size 0
performance_schema_events_transactions_history_long_size 0
performance_schema_events_transactions_history_size 0
performance_schema_events_waits_history_long_size 0
performance_schema_events_waits_history_size 0
server_audit_events

登録されている Event Scheduler リスト確認
show events;

Event Scheduler登録

drop event if exists jKpi_Daily;

delimiter $$
create event jKpi_Daily
on schedule every 1 day
starts '2023-10-24 01:00'
do
begin
SET @LogDate = date_format(DATE_ADD(now(), INTERVAL -1 DAY), '%Y-%m-%d');
    
    
call analysis.pJob_Kpi_Daily(@LogDate);
    
end$$
delimiter ;

コメント