MySQL创建定时任务定时执行sql
#删除定时任务
DROP EVENT IF EXISTS user_event ;
-- 创建名字为user_event的事件
CREATE EVENT `user_event`
ON SCHEDULE EVERY 1 DAY STARTS DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 1 DAY), INTERVAL 1 HOUR) -- 每隔一天执行一次,开始执行时间为明天凌晨1点整
ON COMPLETION NOT PRESERVE
ENABLE
do
BEGIN
update digit_ward_patient.patient_hospitalized_info set admit_date = DATE_FORMAT(sysdate(), '%Y-%m-%d %23:%59:%59') where hosp_no = '10115976';
update user set deleted = 0;
update role set deleted = 0;
end;