【发布时间】:2022-01-24 06:34:48
【问题描述】:
我的表有 2000 万条记录。我最近在该表中添加了另一列。 我需要将数据更新到该列中。 我正在使用 MYSQL 社区版,当我执行这样的直接更新时:
Update Employee SET Emp_mail = 'xyz_123@gmail.com'
系统被挂起,需要突然关闭执行。 但是当我用过滤条件更新语句时,它执行得很好。
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
现在我正在寻找可以分块执行的循环脚本。
例如在 SQL 中是这样的,但我不确定 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
注意:这是一个随机脚本语法,可能会有一些错误。请忽略它。
我正在寻找 MYSQL 中的循环
-
有更新限制的子查询呢?
-
任何方法都可以,只要它在批量更新@AnkitSharma
-
也许会提到有问题的 Adhoc 部分