Found 6705 Articles for Database

How can we start MySQL event scheduler?

Vikyath Ram
Updated on 22-Jun-2020 12:30:22

900 Views

Actually, MySQL event scheduler is a process that runs in the background and constantly looks for the events to execute. But before we create or schedule an event we just have to start the scheduler. It can start with the help of the following statement −mysql> SET GLOBAL event_scheduler = ON; Query OK, 0 rows affected (0.07 sec)Now with the help of the following statement,  we can check its status in MySQL process list −mysql> SHOW PROCESSLIST\G *************************** 1. row ***************************      Id: 3    User: root    Host: localhost:49500      db: query Command: Query    Time: 0   State: ... Read More

How can we put schedule for different kinds of MySQL events?

Ankith Reddy
Updated on 22-Jun-2020 12:32:13

133 Views

Basically, there are two kinds of events for which we need to specify the schedule −One-time eventOne-time event means it will be executed only once on a particular schedule. If we want to create a one-time event then we need to put the following syntax after ON SCHEDULE clause −AT Timestamp[+INTERVAL]Recurring eventsRecurring event means that it will be executed after regular time of interval. If we want to create a recurring event then we need to put the following syntax after ON SCHEDULE clause −EVERY interval STARTS timestamp [+INTERVAL] ENDS timestamp [+INTERVAL]

What is MySQL event and how it is related to trigger?

Venu Madhavi
Updated on 12-Feb-2025 12:08:43

710 Views

Events perform tasks based on a predefined schedule, such as cleaning data once a day or doing backups, while Triggers are activated automatically when some actions are executed, like an INSERT, UPDATE, or DELETE. Despite their differences, events, and triggers can be used together to manage scheduled and reactive automation tasks. This article will show you the relationship and illustrate how they can enhance database management when combined effectively. Relationship Between MySQL Events and Triggers By making use of the strengths of events and triggers, we can design a ideal workflow that can efficiently handle real-time responses and scheduled ... Read More

How can we create a MySQL one-time event that executes immediately?

Lakshmi Srinivas
Updated on 22-Jun-2020 12:20:40

881 Views

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 −Examplemysql> 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 ... Read More

How can we compare data in two MySQL tables?

Prabhas
Updated on 14-Feb-2020 11:09:29

2K+ Views

Sometimes we need to identify the unmatched data from two tables, especially in the case when data is migrated. It can be done by comparing the tables. Consider the example below in which we have two tables named ‘students’ and ‘student1’.mysql> Select * from students; +--------+--------+----------+ | RollNo | Name   | Subject  | +--------+--------+----------+ |    100 | Gaurav | Computer | |    101 | Raman  | History  | |    102 | Somil  | Computer | +--------+--------+----------+ 3 rows in set (0.00 sec) mysql> select * from student1; +--------+--------+----------+ | RollNo | Name | Subject | ... Read More

How will GROUP BY clause perform without an aggregate function?

Krantik Chavan
Updated on 22-Jun-2020 12:31:12

6K+ Views

When we use GROUP BY clause in the SELECT statement without using aggregate functions then it would behave like DISTINCT clause. For example, we have the following table −mysql> Select * from Student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | 125  | Raman   | Shimla     | Computers  | | 130  | Ram     | Jhansi     | Computers  | | 132  | Shyam   | Chandigarh ... Read More

When a MySQL arithmetic expression returns NULL?

seetha
Updated on 22-Jun-2020 12:19:41

139 Views

As we know that a NULL is not a value and it is also not the same as zero. MySQL arithmetic expression returns NULL if we will use NULL in it. It can be understood with the help of the following example −Examplemysql> Select 100*NULL; +----------+ | 100*NULL | +----------+ |     NULL | +----------+ 1 row in set (0.00 sec) mysql> Select 100+NULL; +----------+ | 100+NULL | +----------+ |     NULL | +----------+ 1 row in set (0.00 sec)From the above example, it can be observed that if we will use NULL in an arithmetic expression then the result would be NULL itself.

How can we enter BOOLEAN values in MySQL statement?

Anvi Jain
Updated on 22-Jun-2020 12:20:04

470 Views

As we know that there is no BOOLEAN data type in MySQL hence by using TRUE or true, FALSE or false we can enter Boolean values in MySQL statement.Examplemysql> Select TRUE,FALSE; +------+-------+ | TRUE | FALSE | +------+-------+ | 1    | 0     | +------+-------+ 1 row in set (0.00 sec) mysql> Select true,false; +------+-------+ | TRUE | FALSE | +------+-------+ | 1    | 0     | +------+-------+ 1 row in set (0.00 sec)

How can we enter numerical values as a BINARY number in MySQL statement?

vanithasree
Updated on 22-Jun-2020 12:21:32

138 Views

Following are the two approaches with the help of which we can enter numeric values as a BINARY number −By prefix ‘B’In this approach we need to quote binary numbers within single quotes with a prefix of B. Then BINARY number string will be automatically converted into a numerical value based on the expression context.Examplemysql> Select B'1110'+0; +-----------+ | B'1110'+0 | +-----------+ |        14 | +-----------+ 1 row in set (0.00 sec)By prefix 0bIn this approach, we need to write BINARY numbers without any quotes with a prefix of 0b. Then BINARY number string will be automatically ... Read More

How can we enter characters as a BINARY number in MySQL statement?

Smita Kapse
Updated on 22-Jun-2020 12:22:22

204 Views

Following are the two approaches with the help of which we can enter characters as a BINARY number −By prefix ‘B’In this approach we need to quote binary numbers within single quotes with a prefix of B. Then BINARY number string will be automatically converted into a character string.Examplemysql> Select B'01000001'; +-------------+ | B'01000001' | +-------------+ | A           | +-------------+ 1 row in set (0.00 sec)By prefix 0bIn this approach, we need to write BINARY numbers without any quotes with a prefix of 0b. Then BINARY number string will be automatically converted into a character ... Read More

Advertisements