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教程