Documentation Home

13.7.5.7 显示创建事件语句

SHOW CREATE EVENT event_name

此语句显示CREATE EVENT重新创建给定事件所需的语句。它需要EVENT显示事件的数据库的权限。例如(使用在第 13.7.5.18 节“SHOW EVENTS 语句”e_daily中定义然后更改的相同事件):

mysql> SHOW CREATE EVENT myschema.e_daily\G
*************************** 1. row ***************************
               Event: e_daily
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,
                      NO_ZERO_IN_DATE,NO_ZERO_DATE,
                      ERROR_FOR_DIVISION_BY_ZERO,
                      NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
           time_zone: SYSTEM
        Create Event: CREATE DEFINER=`jon`@`ghidora` EVENT `e_daily`
                        ON SCHEDULE EVERY 1 DAY
                        STARTS CURRENT_TIMESTAMP + INTERVAL 6 HOUR
                        ON COMPLETION NOT PRESERVE
                        ENABLE
                        COMMENT 'Saves total number of sessions then
                                clears the table each day'
                        DO BEGIN
                          INSERT INTO site_activity.totals (time, total)
                            SELECT CURRENT_TIMESTAMP, COUNT(*)
                              FROM site_activity.sessions;
                          DELETE FROM site_activity.sessions;
                        END
character_set_client: utf8
collation_connection: utf8_general_ci
  Database Collation: latin1_swedish_ci

character_set_clientcharacter_set_client是创建事件时系统变量 的会话值。是创建事件时系统变量collation_connection的会话值。是与事件关联的数据库的排序规则。 collation_connectionDatabase Collation

输出反映了事件 ( ENABLE) 的当前状态,而不是创建时的状态。