20.7 The INFORMATION_SCHEMA EVENTS Table

The EVENTS table provides information about scheduled events, which are discussed in Section 19.4, “Using the Event Scheduler”. The SHOW Name values correspond to column names of the SHOW EVENTS statement.

INFORMATION_SCHEMA NameSHOW NameRemarks
EVENT_CATALOG def, MySQL extension
EVENT_SCHEMADbMySQL extension
EVENT_NAMENameMySQL extension
DEFINERDefinerMySQL extension
TIME_ZONETime zoneMySQL extension
EVENT_BODY MySQL extension
EVENT_DEFINITION MySQL extension
EVENT_TYPETypeMySQL extension
EXECUTE_ATExecute atMySQL extension
INTERVAL_VALUEInterval valueMySQL extension
INTERVAL_FIELDInterval fieldMySQL extension
SQL_MODE MySQL extension
STARTSStartsMySQL extension
ENDSEndsMySQL extension
STATUSStatusMySQL extension
ON_COMPLETION MySQL extension
CREATED MySQL extension
LAST_ALTERED MySQL extension
LAST_EXECUTED MySQL extension
EVENT_COMMENT MySQL extension
ORIGINATOROriginatorMySQL extension
CHARACTER_SET_CLIENTcharacter_set_clientMySQL extension
COLLATION_CONNECTIONcollation_connectionMySQL extension
DATABASE_COLLATIONDatabase CollationMySQL extension

Notes:

Example: Suppose that the user jon@ghidora creates an event named e_daily, and then modifies it a few minutes later using an ALTER EVENT statement, as shown here:

DELIMITER |

CREATE EVENT e_daily
    ON SCHEDULE
      EVERY 1 DAY
    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 |

DELIMITER ;

ALTER EVENT e_daily
    ENABLED;

(Note that comments can span multiple lines.)

This user can then run the following SELECT statement, and obtain the output shown:

mysql> SELECT * FROM INFORMATION_SCHEMA.EVENTS
     > WHERE EVENT_NAME = 'e_daily'
     > AND EVENT_SCHEMA = 'myschema'\G
*************************** 1. row ***************************
       EVENT_CATALOG: def
        EVENT_SCHEMA: test
          EVENT_NAME: e_daily
             DEFINER: me@localhost
           TIME_ZONE: SYSTEM
          EVENT_BODY: SQL
    EVENT_DEFINITION: BEGIN
        INSERT INTO site_activity.totals (time, total)
          SELECT CURRENT_TIMESTAMP, COUNT(*)
            FROM site_activity.sessions;
        DELETE FROM site_activity.sessions;
      END
          EVENT_TYPE: RECURRING
          EXECUTE_AT: NULL
      INTERVAL_VALUE: 1
      INTERVAL_FIELD: DAY
            SQL_MODE:
              STARTS: 2008-09-03 12:13:39
                ENDS: NULL
              STATUS: ENABLED
       ON_COMPLETION: NOT PRESERVE
             CREATED: 2008-09-03 12:13:39
        LAST_ALTERED: 2008-09-03 12:13:39
       LAST_EXECUTED: NULL
       EVENT_COMMENT: Saves total number of sessions then clears the
                      table each day
          ORIGINATOR: 1
CHARACTER_SET_CLIENT: latin1
COLLATION_CONNECTION: latin1_swedish_ci
  DATABASE_COLLATION: latin1_swedish_ci

Times in the EVENTS table are displayed using the event time zone or the current session time zone, as described in Section 19.4.4, “Event Metadata”.

See also Section 13.7.5.19, “SHOW EVENTS Syntax”.