I have table which have 20 million records . I have recently added another column to that table. I need to update the data into that column. I’m using MYSQL community edition, when I execute the direct update like this :
Update Employee SET Emp_mail = 'xyz_123@gmail.com'
System Getting hanged and Need to close the execution abruptly. But when I update the statement with filter condition it is executing fine.
Update Employee SET Emp_mail = 'xyz_123@gmail.com' where ID <= 10000;
Update Employee SET Emp_mail = 'xyz_123@gmail.com' where ID >= 10000 AND ID <= 10000 ;
--------
--------
no of Times
Now I’m looking for looping script where I can execute in chunk wise.
For example in SQL it is like this but I’m not sure of MYSQL:
BEGIN
I int = 0 ;
cnt = 0 ;
while 1 > cnt
SET i = i + 1;
Update Employee SET Emp_mail = 'xyz_123@gmail.com' where ID >= cnt AND ID <= I
END
Note : this is a random script syntax wise there may be some errors . Please ignore it.
I’m looking for Looping in MYSQL