- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we create a MySQL one-time event that executes immediately?
As we know a one-time event means the events that will be executed only once on a particular schedule. To illustrate the creation of such kind of events we are using the following example in which we are creating an event which will execute at the current time −
Example
mysql> Create table event_message(ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, MESSAGE VARCHAR(255) NOT NULL, Generated_at DATETIMENOT NULL); Query OK, 0 rows affected (0.61 sec) mysql> CREATE EVENT testing_event ON SCHEDULE AT CURRENT_TIMESTAMP DO INSERT INTO event_message(message,generated_at) Values('Hello',NOW()); Query OK, 0 rows affected (0.00 sec) mysql> Select * from event_message; +----+---------+---------------------+ | ID | MESSAGE | Generated_at | +----+---------+---------------------+ | 1 | Hello | 2017-11-22 17:05:22 | +----+---------+---------------------+ 1 row in set (0.00 sec)
Advertisements