mysql 基礎 事件(定時任務)

1、普通事件:直接執行語句:ide

DROP EVENT IF EXISTS job_insertgood;事件

DELIMITER $$it

CREATE EVENT job_insertgoodevent

ON SCHEDULE EVERY 10 SECONDclass

DO定時任務

BEGINcall

INSERT INTO goods (name,num) VALUES (now(),1);存儲過程

END$$di

DELIMITER ;view

2、事件:調用存儲過程

DROP EVENT IF EXISTS job_callProcedure;

DELIMITER $$

CREATE EVENT job_callProcedure

ON SCHEDULE EVERY 10 SECOND

DO

BEGIN

CALL procedureName();

END$$

DELIMITER ;


3、開啓事件(定時任務):

一、查看
SELECT @@event_scheduler;
或者
SHOW VARIABLES LIKE 'event%'

二、設置:set GLOBAL event_scheduler = 1; 或者SET GLOBAL event_scheduler = ON;

相關文章
相關標籤/搜索