{"id":858,"date":"2020-08-15T20:17:50","date_gmt":"2020-08-15T12:17:50","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=858"},"modified":"2022-03-30T15:26:59","modified_gmt":"2022-03-30T07:26:59","slug":"gbase-8a%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1%e5%8a%9f%e8%83%bdevent%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/858","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u5b9a\u65f6\u4efb\u52a1\u8c03\u5ea6\u529f\u80fdevent\u6d4b\u8bd5"},"content":{"rendered":"\n<p>GBase 8a\u6570\u636e\u5e93\u5185\u90e8\u652f\u6301\u5b9a\u65f6\u4efb\u52a1event\u529f\u80fd\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5185\u90e8\u4efb\u52a1\u8c03\u5ea6\u3002\u4f46\u4e00\u822c\u5efa\u8bae\u8fd8\u662f\u5916\u90e8\u8c03\u5ea6\uff0c\u6bd4\u5982\u901a\u8fc7crontab \u6216\u8005\u5ba2\u6237\u81ea\u5df1\u7684Timer\u529f\u80fd\u7b49\uff0c\u6570\u636e\u5e93\u8fd8\u662f\u805a\u7126\u5728\u6570\u636e\u5b58\u50a8\u548c\u67e5\u8be2\u4e0a\u3002<\/p>\n\n\n\n<p><span class=\"has-inline-color has-luminous-vivid-orange-color\">\u6ce8\u610f\uff1a<\/span>\u5f53\u524d\u7248\u672c\u5e76\u6ca1\u6709\u5bf9\u5927\u89c4\u6a21event\u505a\u652f\u6301\uff0c\u4e00\u822c\u7528\u4e8e\u5185\u90e8\u6e05\u7406\u5783\u573e\uff0c\u505a\u5ba1\u8ba1\u65e5\u5fd7\u5f52\u6863\u7528\uff0c\u6240\u6709\u7684event\u52a0\u8d77\u6765\uff0c\u4e0d\u8981\u8d85\u8fc710\u4e2a\uff0c\u56e0\u4e3a\u5185\u90e8\u7684event\u7ebf\u7a0b\u6570\u597d\u50cf\u662f10\u4e2a\u3002\u8d85\u8fc7\u4e86\u5c31\u4e0d\u4f1a\u6709\u8c03\u5ea6\u4e86\u3002 \u6240\u4ee5\u6700\u597d\u591a\u7528\u4e00\u6b21\u6027\u7684\uff0c\u6267\u884c\u5b8c\u4e86\uff0c\u518d\u521b\u5efa\u4e0b\u4e00\u4e2a\u3002<\/p>\n\n\n\n<p>\u56e0\u4e3a\u662f\u96c6\u7fa4\uff0cGBase 8a\u7684\u5b9a\u65f6\u4efb\u52a1event\u652f\u6301\u4e24\u79cd\u6a21\u5f0f\uff0c\u672c\u5730Local\u548c\u5168\u5c40global\uff08\u9ed8\u8ba4)\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55\u5bfc\u822a<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b0c1a707e8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b0c1a707e8\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%AE%8C%E6%95%B4%E8%AF%AD%E6%B3%95\" >\u5b8c\u6574\u8bed\u6cd5<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA\" >\u521b\u5efa<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E4%BF%AE%E6%94%B9\" >\u4fee\u6539<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E4%BF%AE%E6%94%B9%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E7%9A%84%E8%B0%83%E5%BA%A6%E5%8F%82%E6%95%B0\" >\u4fee\u6539\u5b9a\u65f6\u4efb\u52a1\u7684\u8c03\u5ea6\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E4%BF%AE%E6%94%B9%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E5%90%8D%E5%AD%97\" >\u4fee\u6539\u5b9a\u65f6\u4efb\u52a1\u540d\u5b57<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%A0%E9%99%A4\" >\u5220\u9664<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA%E4%BB%BB%E5%8A%A1%E8%A1%A8%EF%BC%8C%E7%94%A8%E4%BA%8E%E8%AE%B0%E5%BD%95%E6%B5%8B%E8%AF%95%E7%BB%93%E6%9E%9C\" >\u521b\u5efa\u4efb\u52a1\u8868\uff0c\u7528\u4e8e\u8bb0\u5f55\u6d4b\u8bd5\u7ed3\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E4%B8%80%E6%AC%A1%E6%80%A7event\" >\u521b\u5efa\u6700\u7b80\u5355\u7684\u4e00\u6b21\u6027event<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E6%9F%A5%E7%9C%8B%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C\" >\u67e5\u770b\u8fd0\u884c\u7ed3\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E7%AB%8B%E5%8D%B3%E8%BF%90%E8%A1%8C%E7%9A%84event%E5%8F%AF%E8%83%BD%E4%B8%8D%E4%BC%9A%E8%BF%90%E8%A1%8C\" >\u7acb\u5373\u8fd0\u884c\u7684event\u53ef\u80fd\u4e0d\u4f1a\u8fd0\u884c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA%E5%BB%B6%E8%BF%9F%E6%89%A7%E8%A1%8C%E7%9A%84event\" >\u521b\u5efa\u5ef6\u8fdf\u6267\u884c\u7684event<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA%E5%AE%9A%E7%82%B9%E8%BF%90%E8%A1%8C%E7%9A%84event\" >\u521b\u5efa\u5b9a\u70b9\u8fd0\u884c\u7684event<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E6%9F%A5%E7%9C%8Bevent%E6%98%AF%E5%90%A6%E8%BF%98%E5%AD%98%E5%9C%A8\" >\u67e5\u770bevent\u662f\u5426\u8fd8\u5b58\u5728<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E9%98%B6%E6%AE%B5%E6%80%A7%E7%BB%93%E8%AE%BA\" >\u9636\u6bb5\u6027\u7ed3\u8bba<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%88%9B%E5%BB%BA%E5%91%A8%E6%9C%9F%E6%80%A7%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1\" >\u521b\u5efa\u5468\u671f\u6027\u5b9a\u65f6\u4efb\u52a1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C\" >\u6267\u884c\u7ed3\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%85%B6%E5%AE%83%E8%AF%B4%E6%98%8E\" >\u5176\u5b83\u8bf4\u660e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.gbase8.cn\/en\/858\/#%E5%8F%82%E8%80%83\" >\u53c2\u8003<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AE%8C%E6%95%B4%E8%AF%AD%E6%B3%95\"><\/span>\u5b8c\u6574\u8bed\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA\"><\/span>\u521b\u5efa<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE &#91;DEFINER = { user | CURRENT_USER }] EVENT\n&#91;IF NOT EXISTS] event_name\nON SCHEDULE schedule\n&#91;ON COMPLETION &#91;NOT] PRESERVE]\n&#91;ENABLE | DISABLE]\n&#91;global|local]\n&#91;COMMENT 'comment']\nDO event_body;\nschedule:\nAT timestamp &#91;+ INTERVAL interval] ... | EVERY interval\n&#91;STARTS timestamp &#91;+ INTERVAL interval] ...]\n&#91;ENDS timestamp &#91;+ INTERVAL interval] ...]\ninterval:\nquantity { YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |WEEK |\nSECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE | DAY_SECOND | HOUR_MINUTE\n| HOUR_SECOND | MINUTE_SECOND }\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9\"><\/span>\u4fee\u6539<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E7%9A%84%E8%B0%83%E5%BA%A6%E5%8F%82%E6%95%B0\"><\/span>\u4fee\u6539\u5b9a\u65f6\u4efb\u52a1\u7684\u8c03\u5ea6\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; alter event import_audit_log ON SCHEDULE every 10 minute;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.02)\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BF%AE%E6%94%B9%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E5%90%8D%E5%AD%97\"><\/span>\u4fee\u6539\u5b9a\u65f6\u4efb\u52a1\u540d\u5b57<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; alter event import_audit_log rename to import_audit_log2;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%A0%E9%99%A4\"><\/span>\u5220\u9664<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>drop event\uff0c \u5c31\u4e0d\u505a\u4ecb\u7ecd\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; drop event drop_temp_table;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.08)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E4%BB%BB%E5%8A%A1%E8%A1%A8%EF%BC%8C%E7%94%A8%E4%BA%8E%E8%AE%B0%E5%BD%95%E6%B5%8B%E8%AF%95%E7%BB%93%E6%9E%9C\"><\/span>\u521b\u5efa\u4efb\u52a1\u8868\uff0c\u7528\u4e8e\u8bb0\u5f55\u6d4b\u8bd5\u7ed3\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create table tevent(d datetime);\nQuery OK, 0 rows affected (Elapsed: 00:00:00.61)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E6%9C%80%E7%AE%80%E5%8D%95%E7%9A%84%E4%B8%80%E6%AC%A1%E6%80%A7event\"><\/span>\u521b\u5efa\u6700\u7b80\u5355\u7684\u4e00\u6b21\u6027event<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u8be5event\u53ea\u8fd0\u884c\u4e00\u6b21\uff0c\u4e14\u9a6c\u4e0a\u8fd0\u884c\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event1 on schedule at current_timestamp do insert into tevent values(now());\nQuery OK, 0 rows affected (Elapsed: 00:00:00.10)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8B%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C\"><\/span>\u67e5\u770b\u8fd0\u884c\u7ed3\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select * from tevent;\n+---------------------+\n| d |\n+---------------------+\n| 2020-08-15 19:55:53 |\n+---------------------+\n1 row in set (Elapsed: 00:00:00.02)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%AB%8B%E5%8D%B3%E8%BF%90%E8%A1%8C%E7%9A%84event%E5%8F%AF%E8%83%BD%E4%B8%8D%E4%BC%9A%E8%BF%90%E8%A1%8C\"><\/span>\u7acb\u5373\u8fd0\u884c\u7684event\u53ef\u80fd\u4e0d\u4f1a\u8fd0\u884c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u56e0\u4e3a\u521b\u5efa\u65f6\u95f4\u548c\u8c03\u5ea6\u65f6\u95f4\u7684\u504f\u5dee\uff0c\u5982\u4e0a\u7684event,\u6709\u8f83\u5927\u51e0\u7387\u51fa\u73b0\u521a\u521b\u5efa\u5b8c\uff0c\u8fd8\u6ca1\u8fd0\u884c\uff0c\u5c31\u53d1\u73b0\u8fc7\u671f\u4e86\uff0c\u76f4\u63a5\u5c31\u88ab\u5220\u9664\u4e86\uff0c\u5bfc\u81f4event\u6839\u672c\u6ca1\u6709\u88ab\u6267\u884c\u3002\u8bf7\u5728\u5f00\u59cb\u8fd0\u884c\u65f6\u95f4\u505a\u7cbe\u786e\u6307\u5b9a\uff0c\u6216\u8005\u5ef6\u540e\u4e00\u6bb5\u65f6\u95f4\uff0c\u8bf7\u53c2\u8003\u540e\u9762\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event2 on schedule at current_timestamp do insert into tevent values(now());\nQuery OK, 0 rows affected, <span class=\"has-inline-color has-luminous-vivid-orange-color\">1 warning (Elapsed: 00:00:00.10)<\/span>\n\ngbase&gt; show warnings;\n+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+\n| Level | Code | Message                                                                                                                                        |\n+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+\n| Note  | 1588 | 10.0.2.202:5258 - Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. |\n+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E5%BB%B6%E8%BF%9F%E6%89%A7%E8%A1%8C%E7%9A%84event\"><\/span>\u521b\u5efa\u5ef6\u8fdf\u6267\u884c\u7684event<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u901a\u8fc7\u5728current_timestamp\u589e\u52a0\u4e00\u90e8\u5206\u65f6\u95f4\uff0c\u6765\u5ef6\u8fdf\u6267\u884c\u3002\u5982\u6709\u56fa\u5b9a\u65f6\u95f4\uff0c\u8bf7\u53c2\u8003\u540e\u9762\u7684\u5b9a\u65f6\u6267\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event2 on schedule at current_timestamp+interval 10 second do insert into tevent values(now());\nQuery OK, 0 rows affected (Elapsed: 00:00:00.46)\n\ngbase&gt; select * from tevent;\n+---------------------+\n| d                   |\n+---------------------+\n| 2021-10-23 15:35:54 |\n| 2021-10-23 15:47:47 |\n| 2021-10-23 15:48:50 |\n+---------------------+\n3 rows in set (Elapsed: 00:00:00.03)\n\ngbase&gt; select * from tevent;\n+---------------------+\n| d                   |\n+---------------------+\n| 2021-10-23 15:35:54 |\n| 2021-10-23 15:47:47 |\n| 2021-10-23 15:48:50 |\n| 2021-10-23 15:53:15 |\n+---------------------+\n4 rows in set (Elapsed: 00:00:00.03)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E5%AE%9A%E7%82%B9%E8%BF%90%E8%A1%8C%E7%9A%84event\"><\/span>\u521b\u5efa\u5b9a\u70b9\u8fd0\u884c\u7684event<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5982\u4e0bevent,\u4f7f\u7528\u4e86\u7edd\u5bf9\u65f6\u95f4'2021-10-23 15:56:13'\u6765\u6267\u884cevent<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event2 on schedule at '2021-10-23 15:56:13'  do insert into tevent values(now());\nQuery OK, 0 rows affected (Elapsed: 00:00:00.10)\n\ngbase&gt; select * from tevent;\n+---------------------+\n| d                   |\n+---------------------+\n| 2021-10-23 15:35:54 |\n| 2021-10-23 15:47:47 |\n| 2021-10-23 15:48:50 |\n| 2021-10-23 15:53:15 |\n+---------------------+\n4 rows in set (Elapsed: 00:00:00.03)\n\ngbase&gt; select now(),t.* from tevent t;\n+---------------------+---------------------+\n| now()               | d                   |\n+---------------------+---------------------+\n| 2021-10-23 15:56:25 | 2021-10-23 15:35:54 |\n| 2021-10-23 15:56:25 | 2021-10-23 15:47:47 |\n| 2021-10-23 15:56:25 | 2021-10-23 15:48:50 |\n| 2021-10-23 15:56:25 | 2021-10-23 15:53:15 |\n| 2021-10-23 15:56:25 | 2021-10-23 15:56:13 |\n+---------------------+---------------------+\n5 rows in set (Elapsed: 00:00:00.03)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8Bevent%E6%98%AF%E5%90%A6%E8%BF%98%E5%AD%98%E5%9C%A8\"><\/span>\u67e5\u770bevent\u662f\u5426\u8fd8\u5b58\u5728<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><span class=\"has-inline-color has-luminous-vivid-orange-color\">\u6ce8\u610f\uff1a\u5982\u679cevent\u8fd0\u884c\u4e2d\u95f4\u62a5\u9519\uff0c\u5219event\u4e0d\u4f1a\u88ab\u81ea\u52a8\u5220\u9664\u3002<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; show events;\nEmpty set (Elapsed: 00:00:00.00)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%98%B6%E6%AE%B5%E6%80%A7%E7%BB%93%E8%AE%BA\"><\/span>\u9636\u6bb5\u6027\u7ed3\u8bba<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u8ba1\u5212\u4efb\u52a1\u6267\u884c\u7ed3\u679c\u548c\u9884\u671f\u76f8\u7b26\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60f3\u4fdd\u7559\u8fd9\u79cd\u4e00\u6b21\u6027\u7684event\u4eec\u53ef\u4ee5\u901a\u8fc7 ON COMPLETION [NOT] PRESERVE\u6307\u793a\u3002<span class=\"has-inline-color has-luminous-vivid-orange-color\">\u5426\u5219event\u5728\u6267\u884c\u5b8c\u6210\u540e\uff0c\u4f1a\u3010\u81ea\u52a8\u5220\u9664\u3011<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event1 on schedule at current_timestamp on completion preserve do insert into tevent values(now());\nQuery OK, 0 rows affected (Elapsed: 00:00:00.14)\n\ngbase&gt; select * from tevent;\n+---------------------+\n| d                   |\n+---------------------+\n| 2020-08-15 19:55:53 |\n| 2020-08-15 20:02:17 |\n+---------------------+\n2 rows in set (Elapsed: 00:00:00.04)\n\ngbase&gt; show events;\n+--------------+------------------------------------------------------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+-----------+----------+---------------------+----------------+----------------+--------+------+----------+--------------+----------------------+----------------------+--------------------+\n| Vc           | Db                                                               | Name                                                             | Definer                                                                       | Time zone | Type     | Execute at          | Interval value | Interval field | Starts | Ends | Status   | Execute mode | character_set_client | collation_connection | Database Collation |\n+--------------+------------------------------------------------------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+-----------+----------+---------------------+----------------+----------------+--------+------+----------+--------------+----------------------+----------------------+--------------------+\n| vcname000001 | testdb                                                           | test_event1                                                      | root@%                                                                        | +08:00    | ONE TIME | 2020-08-15 20:02:17 | NULL           | NULL           | NULL   | NULL | DISABLED |            1 | utf8                 | utf8_general_ci      | utf8_general_ci    |\n+--------------+------------------------------------------------------------------+------------------------------------------------------------------+-------------------------------------------------------------------------------+-----------+----------+---------------------+----------------+----------------+--------+------+----------+--------------+----------------------+----------------------+--------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p> \u53ef\u4ee5\u770b\u5230event\u88ab\u4fdd\u7559\u4e0b\u6765\u4e86\uff0c\u5f53\u7136\u4e5f\u610f\u5473\u7740\uff0c\u5982\u679c\u4f60\u4e0b\u6b21\u4f7f\u7528\u76f8\u540c\u540d\u5b57\u7684event,\u4f60\u9700\u8981\u81ea\u884c\u6e05\u7406\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%9B%E5%BB%BA%E5%91%A8%E6%9C%9F%E6%80%A7%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1\"><\/span>\u521b\u5efa\u5468\u671f\u6027\u5b9a\u65f6\u4efb\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create event test_event_loop on schedule every 2 second ends current_timestamp+interval 10 second  do insert into tevent values(now());\nQuery OK, 0 rows affected (Elapsed: 00:00:00.33)\n<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e\u4e86\u6bcf2\u79d2\u4e00\u6b21\uff0c\u4e3a\u4e86\u907f\u514d\u6b7b\u5faa\u73af\uff0c\u6211\u4eec\u8bbe\u7f6e\u4e8610\u79d2\u540e\u7ed3\u675f\uff0c\u4e14\u81ea\u52a8\u5220\u9664event\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C\"><\/span>\u6267\u884c\u7ed3\u679c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\ngbase&gt; select * from tevent;\n+---------------------+\n| d                   |\n+---------------------+\n| 2020-08-15 19:55:53 |\n| 2020-08-15 20:02:17 |\n| 2020-08-15 20:11:12 |\n| 2020-08-15 20:11:14 |\n| 2020-08-15 20:11:16 |\n| 2020-08-15 20:11:18 |\n| 2020-08-15 20:11:20 |\n| 2020-08-15 20:11:22 |\n+---------------------+\n8 rows in set (Elapsed: 00:00:00.02)\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%B6%E5%AE%83%E8%AF%B4%E6%98%8E\"><\/span>\u5176\u5b83\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>global \u662f\u9ed8\u8ba4\u7684\uff0c\u4ee3\u8868\u5728\u6574\u4e2a\u96c6\u7fa4\uff0c\u6709\u591a\u4e2a\u7ba1\u7406\u8282\u70b9\u65f6\uff0c\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\u3002 \u800clocal\u8868\u793a\u6bcf\u4e2a\u8282\u70b9\u5404\u81ea\u6267\u884c\uff0c\u4f1a\u51fa\u73b0\u5e76\u53d1\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-\u8001\u7d2b\u7af9\u7684\u5bb6 wp-block-embed-\u8001\u7d2b\u7af9\u7684\u5bb6\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"gVnOH6HVtJ\"><a href=\"https:\/\/www.gbase8.cn\/246\">GBase 8a\u96c6\u7fa4\u6682\u505c\u5b9a\u65f6\u4efb\u52a1event disable<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"\u300aGBase 8a\u96c6\u7fa4\u6682\u505c\u5b9a\u65f6\u4efb\u52a1event disable\u300b\u2014\u8001\u7d2b\u7af9\u7684\u5bb6\" src=\"https:\/\/www.gbase8.cn\/246\/embed#?secret=gVnOH6HVtJ\" data-secret=\"gVnOH6HVtJ\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u5185\u90e8\u652f\u6301\u5b9a\u65f6\u4efb\u52a1event\u529f\u80fd\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5185\u90e8\u4efb\u52a1\u8c03\u5ea6\u3002\u4f46\u4e00\u822c\u5efa\u8bae\u8fd8\u662f\u5916\u90e8\u8c03\u5ea6\uff0c\u6bd4\u5982\u901a\u8fc7crontab \u6216\u8005\u5ba2\u6237\u81ea\u5df1\u7684Timer\u529f\u80fd\u7b49\uff0c\u6570\u636e\u5e93\u8fd8\u662f\u805a\u7126\u5728\u6570\u636e\u5b58\u50a8\u548c\u67e5\u8be2\u4e0a\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-858","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=858"}],"version-history":[{"count":14,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/858\/revisions"}],"predecessor-version":[{"id":9074,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/858\/revisions\/9074"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}