SHOW EVENTS
Description
Displays basic information about all scheduled tasks in a specified schema.
Precautions
Operations related to scheduled tasks are supported only when sql_compatibility is set to 'B'.
Syntax
SHOW EVENTS [{FROM | IN} schema_name] [LIKE 'pattern' | WHERE condition];
Parameters
- {FROM | IN}
Specifies the schema to be queried. By default, the current schema is queried.
- LIKE
Matches a scheduled task by name. If this parameter is not specified, all scheduled tasks in the current schema are printed.
- WHERE
Forms an expression for row selection to narrow down the query range of SHOW EVENTS. condition indicates any expression that returns a value of Boolean type. Rows that do not meet this condition will not be retrieved.
Examples
-- Create and switch to the test database. gaussdb=# CREATE DATABASE test_event WITH DBCOMPATIBILITY = 'b'; test_event=# \c test_event -- Create a schema. test_event=# CREATE SCHEMA test; -- Create a table. test_event=# CREATE TABLE t_ev(num int); -- Create a scheduled task in the current schema by default. test_event=# CREATE EVENT IF NOT EXISTS event_e2 ON SCHEDULE EVERY 1 minute DO insert into t_ev values(1); -- Create a scheduled task in the test schema. test_event=# CREATE EVENT IF NOT EXISTS test.event_e3 ON SCHEDULE EVERY 1 minute DO insert into t_ev values(2); -- View the scheduled tasks. test_event=# SHOW EVENTS; job_name | schema_name | log_user | priv_user | job_status | start_date | interval | end_date | enable | failure_msg ----------+-------------+----------+-----------+------------+----------------------------+----------------------+---------------------+--------+------------------------------- event_e2 | public | omm | omm | s | 2023-11-28 10:13:48.675215 | interval '1' minute | 3999-12-31 16:00:00 | t | (1 rows) -- View the scheduled task in the test schema. test_event=# SHOW EVENTS FROM test; job_name | schema_name | log_user | priv_user | job_status | start_date | interval | end_date | enable | failure_msg ----------+-------------+----------+-----------+------------+----------------------------+----------------------+---------------------+--------+--------------------------------event_e3 | test | omm | omm | s | 2023-11-28 10:29:42.327827 | interval '1' minute | 3999-12-31 16:00:00 | t | (1 row) -- Delete the scheduled tasks. test_event=# DROP EVENT event_e2; test_event=# DROP EVENT test.event_e3; -- Delete the table. test_event=# DROP TABLE t_ev; -- Delete a schema. test_event=# DROP SCHEMA test; -- 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.