All Products
Search
Document Center

ApsaraDB RDS:Configure a cyclic event on an ApsaraDB RDS for MySQL instance

Last Updated:Sep 06, 2023

This topic describes how to use Data Management (DMS) to cyclically execute an event on an ApsaraDB RDS for MySQL instance.

Prerequisites

The event scheduler is enabled for the database to which you log on. You can execute the SELECT @@event_scheduler; statement to check whether the event scheduler is enabled.

  • If ON is returned, the event scheduler is enabled.

  • If OFF is returned, the event scheduler is disabled.

Procedure

For this example, execute a cyclic event to increase 1 to the value of the test1 field with an ID of 10 every two minutes.

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
  2. In the upper-right corner, click Log On to Database. Then, use the privileged account of your RDS instance to log on to the database. For more information, see Use DMS to log on to an ApsaraDB RDS for MySQL instance.

  3. Click the Programmable Object tab, right-click Event, and then select New (Event).

  4. Configure the following parameters.

    Section

    Parameter

    Description

    Event Basic Information

    Event Name

    The name of the event.

    Status

    The status of the event. Valid values:

    • Open: The event is executable.

    • Disable: The event is not executable.

    • Disable from DB: The event can be executed only on the primary database.

    Due deletion

    • Specifies whether to delete the event after the event is executed at the specified point in time.

    • Specifies whether to delete the event after the event is executed at specified intervals for the specified period of time.

    Note

    The annotation of the event.

    Execution time definition

    Scheduling mode

    • Fixed time: The event is executed at a fixed point in time. If you select this mode, you must configure the Fixed Time parameter.

    • Cyclic time: The event is executed at specified intervals. You must configure the Interval, Start time, and End time parameters.

      Note
      • Interval: The value of this parameter consists of an integer and a time unit. The value of this parameter indicates the interval at which you want to execute the event.

      • Start time: The start time of the event. If you do not configure this parameter, the system immediately executes the event.

      • End time: The end time of the event. If you do not configure this parameter, the system infinitely executes the event.

    Event statement

    N/A

    The SQL statement that you want to execute.

    The following examples show the intervals at which a cyclic event is executed:

    • Based on the following settings, the event is executed at two-minute intervals after the specified start time.

    • Based on the following settings, the event is executed at one-month intervals after the specified start time.

  5. Enter the SQL statement in the Event Statement (*) section and click Save. In the Submit dialog box, confirm the SQL statement and click Execute.

  6. Execute the SHOW EVENTS; statement in the database to query the cyclic event.

    Note

    If you want to delete the cyclic event, execute the DROP EVENT <The name of the cyclic event>; statement.