MySQL的定时任务(每天凌晨3点钟执行)
//创建测试表DROP表
IF EXISTS演示;
CREATE TABLE演示(时间轴TIMESTAMP);
//为测试表,创建定时任务(每天凌晨3点钟,插入数据)
DROP EVENT IF EXISTS event _ demo _ insert; CREATE EVENT event _ demo _ insert on schedule EVERY 1 DAY STARTS date_add(date(curdate()+1), interval 3 hours) INSERT INTO demo value(CURRENT_TIMESTAMP);
##修正后的代码:
//创建测试表
DROP table IF EXISTS demo;
CREATE TABLE演示(时间轴TIMESTAMP);
//为测试表,创建定时任务(每天凌晨3点钟,插入数据)
DROP EVENT IF EXISTS event _ demo _ insert; CREATE EVENT event_demo_insert on schedule EVERY 1 DAY STARTS date_add(date( ADDDATE(curdate(),1)),interval 3 hour) do INSERT INTO demo value(CURRENT_TIMESTAMP);