這篇文章將為大家詳細講解有關(guān)MySQL 5.5如何創(chuàng)建和查看數(shù)據(jù)庫計劃任務(wù),小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
專注于為中小企業(yè)提供網(wǎng)站設(shè)計、做網(wǎng)站服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)新民免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
--查看相關(guān)參數(shù)
mysql> show variables like '%event%';
+---------------------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------------------+-------+
| event_scheduler | OFF |
| performance_schema_events_waits_history_long_size | 10000 |
| performance_schema_events_waits_history_size | 10 |
+---------------------------------------------------+-------+
3 rows in set (0.00 sec)
--開啟相關(guān)參數(shù)
mysql> set global event_scheduler = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%event%';
+---------------------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------------------+-------+
| event_scheduler | ON |
| performance_schema_events_waits_history_long_size | 10000 |
| performance_schema_events_waits_history_size | 10 |
+---------------------------------------------------+-------+
3 rows in set (0.00 sec)
--開啟參數(shù)后,在線程中會出現(xiàn)event_scheduler相關(guān)線程
mysql> show processlist\G
*************************** 7. row ***************************
Id: 13
User: event_scheduler
Host: localhost
db: NULL
Command: Daemon
Time: 474
State: Waiting for next activation
Info: NULL
7 rows in set (0.00 sec)
--創(chuàng)建計劃任務(wù)
mysql> CREATE EVENT myevent
-> ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
-> DO
-> UPDATE fire.t12 SET sal = sal + 100;
Query OK, 0 rows affected (0.02 sec)
--查看數(shù)據(jù)庫里面的計劃任務(wù)
mysql> show events from fire\G
*************************** 1. row ***************************
Db: fire
Name: myevent
Definer: system@localhost
Time zone: SYSTEM
Type: ONE TIME
Execute at: 2016-05-23 02:48:03
Interval value: NULL
Interval field: NULL
Starts: NULL
Ends: NULL
Status: ENABLED
Originator: 100
character_set_client: gbk
collation_connection: gbk_chinese_ci
Database Collation: utf8_general_ci
1 row in set (0.00 sec)
--查看計劃任務(wù)的內(nèi)容
mysql> show create event myevent\G
*************************** 1. row ***************************
Event: myevent
sql_mode: STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
time_zone: SYSTEM
Create Event: CREATE DEFINER=`system`@`localhost` EVENT `myevent` ON SCHEDULE AT '2016-05-23 02:48:03' ON COMPLETION NOT PRESERVE ENABLE DO UPDATE fire.t12 SET sal = sal + 100
character_set_client: gbk
collation_connection: gbk_chinese_ci
Database Collation: utf8_general_ci
1 row in set (0.00 sec)
--禁止計劃任務(wù)
mysql> ALTER EVENT myevent DISABLE;
關(guān)于“MySQL 5.5如何創(chuàng)建和查看數(shù)據(jù)庫計劃任務(wù)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。