Home > Database > Mysql Tutorial > body text

mysql定时任务与存储过程实例_MySQL

WBOY
Release: 2016-06-01 13:17:32
Original
1127 people have browsed it

/**查看event是否开启 : SHOW VARIABLES LIKE '%event_sche%';将事件计划开启 : SET GLOBAL event_scheduler = 1; 将事件计划关闭 : SET GLOBAL event_scheduler = 0; 关闭事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE DISABLE; 开启事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE ENABLE; 查看事件任务 : SHOW EVENTS ;delimiter //   设定语句终结符为 //,因存储过程语句用;结束 **/DROP TABLE IF EXISTS test;                CREATE TABLE test (  id           bigint(11) unsigned NOT NULL AUTO_INCREMENT,  name         varchar(100) NOT NULL DEFAULT '',  create_time  datetime,  PRIMARY KEY (ID)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;DELIMITER //DROP PROCEDURE IF EXISTS p_test//CREATE PROCEDURE p_test()  BEGIN  INSERT INTO test(name, create_time) values('testName', now());END//DROP EVENT IF EXISTS e_test//CREATE EVENT e_test  ON SCHEDULE EVERY 10 second STARTS TIMESTAMP '2014-04-09 01:00:00' ON COMPLETION PRESERVE  DO BEGIN   CALL p_test();END//
Copy after login

以上事件e_test表示每10秒执行一次p_test()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!