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 Name | SHOW Name | Remarks |
|---|---|---|
EVENT_CATALOG | def, MySQL extension | |
EVENT_SCHEMA | Db | MySQL extension |
EVENT_NAME | Name | MySQL extension |
DEFINER | Definer | MySQL extension |
TIME_ZONE | Time zone | MySQL extension |
EVENT_BODY | MySQL extension | |
EVENT_DEFINITION | MySQL extension | |
EVENT_TYPE | Type | MySQL extension |
EXECUTE_AT | Execute at | MySQL extension |
INTERVAL_VALUE | Interval value | MySQL extension |
INTERVAL_FIELD | Interval field | MySQL extension |
SQL_MODE | MySQL extension | |
STARTS | Starts | MySQL extension |
ENDS | Ends | MySQL extension |
STATUS | Status | MySQL extension |
ON_COMPLETION | MySQL extension | |
CREATED | MySQL extension | |
LAST_ALTERED | MySQL extension | |
LAST_EXECUTED | MySQL extension | |
EVENT_COMMENT | MySQL extension | |
ORIGINATOR | Originator | MySQL extension |
CHARACTER_SET_CLIENT | character_set_client | MySQL extension |
COLLATION_CONNECTION | collation_connection | MySQL extension |
DATABASE_COLLATION | Database Collation | MySQL extension |
Notes:
The
EVENTStable is a nonstandard table.EVENT_CATALOG: The value of this column is alwaysdef.EVENT_SCHEMA: The name of the schema (database) to which this event belongs.EVENT_NAME: The name of the event.DEFINER: The account of the user who created the event, in'format.user_name'@'host_name'TIME_ZONE: The event time zone, which is the time zone used for scheduling the event and that is in effect within the event as it executes. The default value isSYSTEM.EVENT_BODY: The language used for the statements in the event'sDOclause; in MySQL 5.5, this is alwaysSQL.This column is not to be confused with the column of the same name (now named
EVENT_DEFINITION) that existed in earlier MySQL versions.EVENT_DEFINITION: The text of the SQL statement making up the event'sDOclause; in other words, the statement executed by this event.EVENT_TYPE: The event repetition type, eitherONE TIME(transient) orRECURRING(repeating).EXECUTE_AT: For a one-time event, this is theDATETIMEvalue specified in theATclause of theCREATE EVENTstatement used to create the event, or of the lastALTER EVENTstatement that modified the event. The value shown in this column reflects the addition or subtraction of anyINTERVALvalue included in the event'sATclause. For example, if an event is created usingON SCHEDULE AT CURRENT_TIMESTAMP + '1:6' DAY_HOUR, and the event was created at 2006-02-09 14:05:30, the value shown in this column would be'2006-02-10 20:05:30'.If the event's timing is determined by an
EVERYclause instead of anATclause (that is, if the event is recurring), the value of this column isNULL.INTERVAL_VALUE: For recurring events, this column contains the numeric portion of the event'sEVERYclause.For a one-time event (that is, an event whose timing is determined by an
ATclause), this column isNULL.INTERVAL_FIELD: For recurring events, this column contains the units portion of theEVERYclause governing the timing of the event. Thus, this column contains a value such as 'YEAR', 'QUARTER', 'DAY', and so on.For a one-time event (that is, an event whose timing is determined by an
ATclause), this column isNULL.SQL_MODE: The SQL mode in effect at the time the event was created or altered.STARTS: For a recurring event whose definition includes aSTARTSclause, this column contains the correspondingDATETIMEvalue. As with theEXECUTE_ATcolumn, this value resolves any expressions used.If there is no
STARTSclause affecting the timing of the event, this column isNULLENDS: For a recurring event whose definition includes aENDSclause, this column contains the correspondingDATETIMEvalue. As with theEXECUTE_ATcolumn, this value resolves any expressions used.If there is no
ENDSclause affecting the timing of the event, this column isNULL.STATUS: One of the three valuesENABLED,DISABLED, orSLAVESIDE_DISABLED.SLAVESIDE_DISABLEDindicates that the creation of the event occurred on another MySQL server acting as a replication master and was replicated to the current MySQL server which is acting as a slave, but the event is not presently being executed on the slave. See Section 17.4.1.8, “Replication of Invoked Features”, for more information.ON_COMPLETION: One of the two valuesPRESERVEorNOT PRESERVE.CREATED: The date and time when the event was created. This is aDATETIMEvalue.LAST_ALTERED: The date and time when the event was last modified. This is aDATETIMEvalue. If the event has not been modified since its creation, this column holds the same value as theCREATEDcolumn.LAST_EXECUTED: The date and time when the event last executed. ADATETIMEvalue. If the event has never executed, this column isNULL.LAST_EXECUTEDindicates when the event started. As a result, theENDScolumn is never less thanLAST_EXECUTED.EVENT_COMMENT: The text of a comment, if the event has one. If not, the value of this column is an empty string.ORIGINATOR: The server ID of the MySQL server on which the event was created; used in replication. The default value is 0.CHARACTER_SET_CLIENTis the session value of thecharacter_set_clientsystem variable when the event was created.COLLATION_CONNECTIONis the session value of thecollation_connectionsystem variable when the event was created.DATABASE_COLLATIONis the collation of the database with which the event is associated.
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: paul@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 12.4.5.19, “SHOW EVENTS Syntax”.