I have a MySQL database. I am running two MySQL EVENTs. I need to get rid of one. I don't remember it's name. What do I do?
its simple SHOW EVENTS
lists all of the events in the current schema
To see events for a specific schema, use the FROM clause. For example, to see events for the test schema, use the following statement:
SHOW EVENTS FROM test;
The information_schema.EVENTS
table is where to start.
USE information_schema;
DESCRIBE EVENTS;
+----------------------+---------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------------+------+-----+---------------------+-------+
| EVENT_CATALOG | varchar(64) | YES | | NULL | |
| EVENT_SCHEMA | varchar(64) | NO | | | |
| EVENT_NAME | varchar(64) | NO | | | |
| DEFINER | varchar(77) | NO | | | |
| TIME_ZONE | varchar(64) | NO | | | |
| EVENT_BODY | varchar(8) | NO | | | |
| EVENT_DEFINITION | longtext | NO | | NULL | |
| EVENT_TYPE | varchar(9) | NO | | | |
| EXECUTE_AT | datetime | YES | | NULL | |
| INTERVAL_VALUE | varchar(256) | YES | | NULL | |
| INTERVAL_FIELD | varchar(18) | YES | | NULL | |
| SQL_MODE | varchar(8192) | NO | | | |
| STARTS | datetime | YES | | NULL | |
| ENDS | datetime | YES | | NULL | |
| STATUS | varchar(18) | NO | | | |
| ON_COMPLETION | varchar(12) | NO | | | |
| CREATED | datetime | NO | | 0000-00-00 00:00:00 | |
| LAST_ALTERED | datetime | NO | | 0000-00-00 00:00:00 | |
| LAST_EXECUTED | datetime | YES | | NULL | |
| EVENT_COMMENT | varchar(64) | NO | | | |
| ORIGINATOR | bigint(10) | NO | | 0 | |
| CHARACTER_SET_CLIENT | varchar(32) | NO | | | |
| COLLATION_CONNECTION | varchar(32) | NO | | | |
| DATABASE_COLLATION | varchar(32) | NO | | | |
+----------------------+---------------+------+-----+---------------------+-------+
SELECT EVENT_NAME FROM EVENTS WHERE EVENT_SCHEMA = 'your_database_name';
USE information_schema; DESCRIBE EVENTS; SELECT * FROM EVENTS;
–
Dint Show events with more details
SELECT * FROM information_schema.EVENTS
SHOW EVENTS\G
Which will bring you the list of all existing events. For Show Events Syntax: http://dev.mysql.com/doc/refman/5.1/en/show-events.html
If you want to view all Event Schedulers from all databases in MySQL.
SELECT * FROM information_schema.EVENTS;
If you want to view all Event Schedulers from a specific database in MySQL.
SHOW EVENTS FROM 'your_database_name';
Event Scheduler Specific Query:
SELECT EVENT_DEFINITION
FROM information_schema.EVENTS
WHERE EVENT_NAME = 'your_event_name';
Database Specific Event Scheduler Query:
SELECT EVENT_DEFINITION
FROM information_schema.EVENTS
WHERE EVENT_NAME = 'your_event_name'
AND EVENT_SCHEMA = 'your_database_name';
You can show all events with the SQL below. *The doc explains INFORMATION_SCHEMA.EVENTS
table and I recommend to use \G which can show them more clearly and the SQL below can show more details than SHOW EVENTS which I explain last:
SELECT * FROM INFORMATION_SCHEMA.EVENTS;
Or:
SELECT * FROM INFORMATION_SCHEMA.EVENTS\G
And, you can show the events of apple
database with the SQL below:
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA = 'apple';
And, you can show the events running currently with the SQL below:
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE STATUS = 'ENABLED';
And, you can show the events not running currently with the SQL below:
SELECT * FROM INFORMATION_SCHEMA.EVENTS WHERE STATUS = 'DISABLED';
And, you can show the events of apple
database selecting apple
database with USE. *The doc explains SHOW EVENTS
and I recommend to use \G
which can show them more clearly:
USE apple;
SHOW EVENTS;
Or:
USE apple;
SHOW EVENTS\G
Or:
USE apple;
SHOW EVENTS FROM apple;
Or:
USE apple;
SHOW EVENTS FROM apple\G
And, you can show the events running currently of apple
database selecting apple
database with USE
:
USE apple;
SHOW EVENTS WHERE STATUS = 'ENABLED';
And, you can show the events not running currently of apple
database selecting apple
database with USE
:
USE apple;
SHOW EVENTS WHERE STATUS = 'DISABLED';
And, you can show the events of orange
database even if selecting apple
database with USE
:
USE apple;
SHOW EVENTS FROM orange;
And, you can show the events of apple
database not selecting any one of databases with USE
:
SHOW EVENTS FROM apple;
Be careful, if you run the SQL below not selecting any one of databases with USE
:
SHOW EVENTS;
Then, there is the error below:
ERROR 1046 (3D000): No database selected
© 2022 - 2024 — McMap. All rights reserved.
show processlist;
? Is that what you're looking for? – Ashjian