You can use Alibaba Cloud Data Management (DMS) to cyclically execute an event on an ApsaraDB RDS for MySQL instance.
The event scheduler is enabled for the database to which you log on. You can execute
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. Execute the
SET GLOBAL event_scheduler = ON;statement to enable the event scheduler.
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.
- Log on to the ApsaraDB for RDS console.
- In the top navigation bar, select the region where the target RDS instance resides.
- Find the target RDS instance and click its ID.
- In the upper-right corner, click Log On to DB. Then, use the privileged account of the target RDS instance to log on to the target database. For more information, see Use DMS to log on to an ApsaraDB for RDS instance.
- In the top navigation bar of the Home page, choose . The New: Event tab appears.
- Configure the following parameters.
Section Parameter Description Basic Information Event Name The name of the event. Delete It After Expiration
- 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.
Status The status of the event. Valid values:
- Enable: The event is executable.
- Disable: The event is not executable.
- DISABLE ON: The event can be executed only on the primary database.
Annotation The annotation of the event. Execute At Fixed Time The point in time at which you want to execute the event. Cycle Time The time interval at which you want to execute the event.Note The value of this parameter consists of two parts: integer and unit. Start Time The start time of the period during which you want to execute the event at intervals. End time The end time of the period during which you want to execute the event at intervals. Event Syntax - The SQL statement that you want to execute.
The following examples show the time 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.
- Click Save. In the Yes dialog box, confirm the SQL statement that you want to execute, and click OK.
- Execute the
SHOW EVENTS;statement in the target 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.