See how much time is left for a given event to happen - [mysql]

0

I'm new to mysql and have an event created in the mysql database, and was wondering if you have any way to check when it's still time for that event to run.

Is that possible?

    
asked by anonymous 11.07.2018 / 22:32

1 answer

0

In the MySQL documentation says you should use INFORMATION_SCHEMA to redeem information about an event. The field you will use to find out how much time is missing is STARTS

 SELECT * FROM INFORMATION_SCHEMA.EVENTS
   WHERE EVENT_NAME = 'e_daily'
     AND EVENT_SCHEMA = 'myschema';

The result is:

*************************** 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
    
11.07.2018 / 22:53