MYSQL 事件高度器_MySQL教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:MySQL如何设置密码
MySQL设置密码有很多方法: 1.用root 进入mysql后 mysqlset password =password('你的密码'); mysqlflush privileges; 2.使用GRANT语句 mysqlgrant all on *.* to 'root'@'localhost' IDENTIFIED BY '你的密码'with grant option ; mysqlflush privileges; 3.进入mysql

要查看当前是否已开启事件调度器
SHOW VARIABLES LIKE 'event_scheduler';

开启事件高度器
SET GLOBAL event_scheduler = 1;

创建事件
语法:
CREATE EVENT [IF NOT EXISTS] event_name
ON SCHEDULE schedule
[ON COMPLETION [NOT] PRESERVE]
[ENABLE | DISABLE]
[COMMENT 'comment']
DO sql_statement;

实例:
CREATE EVENT updateInfoStatus  
ON SCHEDULE EVERY 30 MINUTE   
DO 
UPDATE `jd_article` SET `status` = 0 WHERE `status` = 1 AND `date` <= now( );

修改事件
语法:
ALTER EVENT event_name
[ON SCHEDULE schedule]
[RENAME TO new_event_name]
[ON COMPLETION [NOT] PRESERVE]
[COMMENT 'comment']
[ENABLE | DISABLE]
[DO sql_statement]

实例:
ALTER EVENT updateInfoStatus  
ON SCHEDULE EVERY 30 MINUTE   
DO 
UPDATE `jd_article` SET `status` = 0 WHERE `status` = 1 AND `date` <= now( );

删除事件
DROP EVENTS IF EXISTS updateInfoStatus

临时关闭事件
ALTER EVENTS updateInfoStatus DISABLE

开启事件
ALTER EVENTS updateInfoStatus ENABLE

查看事件详细信息
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'updateInfoStatus' AND EVENT_SCHEMA = 'jdwc'

查看所有事件
SHOW EVENTS

查看事件创建信息
SHOW CREATE EVENT updateInfoStatus

分享:Ubuntu 11.04 x64 编译安装mysql
Ubuntu 11.04 x64 编译安装mysql OS:Ubuntu 11.04 x64 手动安装mysql 5.5.17 什么是mysqlnd:http://cn.php.net/manual/zh/mysqli.overview.php#mysqli.overview.mysqlnd mysqli、mysql、pdo_mysql的区别:http://cn.php.net/manual/zh/mysqli.overview.php#mysqli.ov

来源:未知//所属分类:MySQL教程/更新时间:2012-07-20
相关MySQL教程