DROP EVENT
Description
Deletes a scheduled task.
Precautions
Operations related to scheduled tasks are supported only when sql_compatibility is set to 'B'.
Syntax
DROP EVENT [IF EXISTS] event_name;
Parameters
- IF EXISTS
If the scheduled task does not exist, a NOTICE message is displayed.
Examples
-- Create and switch to the test database. gaussdb=# CREATE DATABASE test_event WITH DBCOMPATIBILITY = 'b'; gaussdb=# \c test_event -- Create a table. test_event=# CREATE TABLE t_ev(num int); -- Create a scheduled event that is executed once every five seconds. After the event is executed, the scheduled event is automatically deleted. test_event=# CREATE EVENT IF NOT EXISTS event_e1 ON SCHEDULE AT sysdate + interval 5 second DO INSERT INTO t_ev VALUES(0); -- Query the table five seconds later. test_event=# SELECT * FROM t_ev; num ----- 0 (1 row) -- Create a scheduled event that is executed every minute. test_event=# CREATE EVENT IF NOT EXISTS event_e2 ON SCHEDULE EVERY 1 minute DO INSERT INTO t_ev VALUES(1); -- Query the table every one minute. A new record is displayed. test_event=# SELECT * FROM t_ev; num ----- 0 1 1 (3 rows) -- Delete the scheduled event. test_event=# DROP EVENT event_e2; -- Drop the table. test_event=# DROP TABLE t_ev; -- Switch back to the initial database and delete the test database. Replace postgres with the actual database name. test_event=#\c postgres gaussdb=# DROP DATABASE test_event;
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.