mysql之事件的开启和调用
1、检测事件是否开启
mysql> show variables like 'event_scheduler';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | OFF |
+-----------------+-------+
1 row in set (0.00 sec)
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | OFF |
+-----------------+-------+
1 row in set (0.00 sec)
2、开启事件
mysql> show variables like 'event_scheduler';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | ON |
+-----------------+-------+
1 row in set (0.00 sec)
3、创建一个存储过程
1
2
3
4
5
|
delimiter // create procedure test() begin update test fdCreate = now(); end ; |
4、创建一个事件
1
2
3
4
|
create event if not exists e_test on schedule every 30 second on completion preserve do call test(); |
5、关闭或开启执行事件
1
|
alter event event_name on completion preserve [enable | disable] |
6、删除事件
1
|
drop event event_name; |