Found 6705 Articles for Database

How can we get the metadata of MySQL events?

Ankith Reddy
Updated on 22-Jun-2020 12:45:07

169 Views

It can be done with the help of the INFORMATION_SCHEMA database. The following statement will give us the metadata of events −mysql> SELECT * from INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME LIKE '%event%' A ND EVENT_SCHEMA = 'query'\G *************************** 1. row ***************************       EVENT_CATALOG: def        EVENT_SCHEMA: query          EVENT_NAME: testing_event6             DEFINER: root@localhost           TIME_ZONE: SYSTEM          EVENT_BODY: SQL    EVENT_DEFINITION: INSERT INTO event_message(message, generated_at) values('EVENT ALTERED', NOW())          EVENT_TYPE: ONE TIME          EXECUTE_AT: 2017-11-22 20:03:52 ... Read More

How can I move an existing MySQL event to another database?

Manikanth Mani
Updated on 22-Jun-2020 12:51:23

213 Views

It can be done with the help of ALTER EVENT statement too. We need to use the combination of database name and event name along with the RENAME keyword. To illustrate it we are having the following example in which we are moving the event named ‘hello_renamed’ from ‘query’ database to ‘tutorial’ database −Examplemysql> ALTER EVENT query.hello_renamed RENAME to tutorials.hello_renamed; Query OK, 0 rows affected (0.00 sec)To confirm that event has been moved to database ‘tutorials’ we can try to delete the event with an old name, MySQL will throw an error as follows −mysql> DROP event hello_renamed; ERROR 1539 (HY000): Unknown ... Read More

How can we RENAME an existing MySQL event?

Paul Richard
Updated on 22-Jun-2020 12:33:25

130 Views

With the help of ALTER EVENT statement along with the RENAME keyword, we can RENAME an existing event. To illustrate it we are having the following example in which we are renaming the event ‘Hello’ to ‘Hello_renamed’ −Examplemysql> ALTER EVENT Hello RENAME TO Hello_renamed; Query OK, 0 rows affected (0.00 sec)To confirm that event has been renamed we can try to delete the event with the old name, MySQL will throw an error as follows −mysql> DROP EVENT hello; ERROR 1539 (HY000): Unknown event 'hello'

How can we ENABLE AND DISABLE a particular MySQL event?

Sai Nath
Updated on 22-Jun-2020 12:38:29

2K+ Views

With the help of ALTER EVENT statement along with the ENABLE and DISABLE keyword, we can ENABLE and DISABLE the event. To illustrate it we are having the following example −Examplemysql> ALTER EVENT hello DISABLE; Query OK, 0 rows affected (0.00 sec)The above query will DISABLE the event named ‘Hello’ and the query below will enable it.mysql> ALTER EVENT hello ENABLE; Query OK, 0 rows affected (0.00 sec)

How can we modify an existing MySQL event?

Samual Sam
Updated on 22-Jun-2020 12:34:23

402 Views

With the help of ALTER EVENT statement, we can modify an existing MySQL event. We can change the various attributes of an event. ALTER EVENT has the following syntax −   ALTER EVENT event_name     ON SCHEDULE schedule ON COMPLETION [NOT] PRESERVE   RENAME TO new_event_name     ENABLE | DISABLE            DO        event_bodyTo understand it we are illustrating the example as below −ExampleSuppose we have an event as follows −mysql> Create event hello ON SCHEDULE EVERY 1 Minute DO INSERT INTO event_messages(message, generated_at) Values ('Alter event testing', NOW()); Query OK, 0 rows ... Read More

How can we delete an existing MySQL event permanently?

Anjana
Updated on 22-Jun-2020 12:26:04

270 Views

We need to use the DROP statement to delete an existing MySQL event permanently. To illustrate it we are deleting the event named testing_event as follows −Examplemysql> DROP EVENT testing_event; Query OK, 0 rows affected (0.00 sec)

How can we simulate the MySQL INTERSECT query returning multiple expressions?

Giri Raju
Updated on 22-Jun-2020 12:35:18

163 Views

Since we cannot use the INTERSECT query in MySQL, we will use the EXIST operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ |       101 | YashPal | Amritsar   | History    | |       105 | Gaurav  | Chandigarh | Literature | |       130 | Ram     ... Read More

How can we simulate the MySQL INTERSECT query having WHERE clause?

Abhinaya
Updated on 22-Jun-2020 12:49:51

157 Views

Since we cannot use INTERSECT query in MySQL, we will use IN operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ |       101 | YashPal | Amritsar   | History    | |       105 | Gaurav  | Chandigarh | Literature | |       130 | Ram     | Jhansi ... Read More

How can we simulate the MySQL INTERSECT query?

Jennifer Nicholas
Updated on 22-Jun-2020 12:50:41

201 Views

Since we cannot use INTERSECT query in MySQL, we will use IN operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ | 101       | YashPal | Amritsar   | History    | | 105       | Gaurav  | Chandigarh | Literature | | 130       | Ram     | Jhansi ... Read More

How to delete the duplicate values stored in reverse order from MySQL table?

Govinda Sai
Updated on 22-Jun-2020 12:35:57

287 Views

To understand this concept, we are using the data from table ‘Details_city’ as follows −mysql> Select * from details_city; +--------+--------+ | City1  | City2  | +--------+--------+ | Delhi  | Nagpur | | Delhi  | Mumbai | | Nagpur | Delhi  | | Katak  | Delhi  | | Delhi  | Katak  | +--------+--------+ 5 rows in set (0.00 sec)Now, the following query will delete the reverse duplicate values from details_city table −mysql> Select a.city1,a.city2 from details_city a WHERE a.city1

Advertisements