sql关联查询更新速度慢的问题

原语句

update B b
set b.fid =
(select f.id from F f where f.bid = b.id) ;

可以考虑用

begin

  for f in (select f.id,f.bid from F f) loop

    update B set b.fid=f.id where b.id=f.bid;

  end loop;

end;

这样时间可以省略跟多倍  已1000条数据为例  第一条sql语句需要 27s  第二种 只需要 0.062s ;

参考文章:http://www.yyjjssnn.cn/articles/765.html

原文地址:https://www.cnblogs.com/liangbo-/p/11150485.html