Mysql Event

 查看是否启用了Mysql event

 mysql> select @@event_scheduler;
 mysql> show variables like 'event_scheduler';

  如果没有开启,开启它。
 mysql> set GLOBAL event_scheduler=ON;
 或
 mysql> set GLOBAL event_scheduler=1;
 

   创建event

 create event e_test on schedule every 5 second starts timestamp '2010-01-12 23:22:00' enable do

 select * from mysql.event;

 修改event

alter event e_test on schedule every 1 day starts timestamp '2010-01-12 23:22:00' enable do

 select * from mysql.event;

 

删除event

drop event e_test;

 

启用和禁用event

alter event e_test enable;

alter event e_test disable;

查看event

show events\G;

select * from INFORMATION_SCHEMA.EVENT;

SHOW EVENTS [FROM schema_name]
    [LIKE 'pattern' | WHERE expr]

 

查看event创建脚本

SHOW CREATE EVENT event_name
show create event event_name\G

创建event语法

CREATE  [DEFINER = { user | CURRENT_USER }]

EVENT

[IF NOT EXISTS]

event_name

ON SCHEDULE schedule

[ON COMPLETION [NOT] PRESERVE]

[ENABLE | DISABLE | DISABLE ON SLAVE]

[COMMENT ''comment'']

DO sql_statement;

 

schedule:

AT timestamp [+ INTERVAL interval]

| EVERY interval

[STARTS timestamp [+ INTERVAL interval]]

[ENDS timestamp [+ INTERVAL interval]]

 

interval:

quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |

WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |

DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}

 

修改event语法

ALTER EVENT event_name

    [ON SCHEDULE schedule]

    [RENAME TO new_event_name]

    [ON COMPLETION [NOT] PRESERVE]

    [COMMENT ''comment'']

    [ENABLE | DISABLE]

[DO sql_statement]

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值