update tableA a,(select a.netbar_id,sum(a.reward_amt) reward_amt from  tableB a group by a.netbar_id) b set a.transfer_amt=b.reward_amt where a.netbar_id=b.netbar_id;

执行该语句时要注意,因为

select a.netbar_id,sum(a.reward_amt) reward_amt from  tableB a group by a.netbar_id

该临时表没有建索引,所以当记录比较多时,再执行update操作就会出现阻塞,因为执行update操作会锁表。

所以要改写成用脚本。

用脚本查询得到临时表,然后用循环把每条纪录的netbar_id取出来做为update的where条件,这样update执行的时间就会很短。

update与join的联合操作

UPDATE table A
LEFT JOIN
table B
ON
A.B_ID = B.B_ID
SET
A.A_NAME = B.B_NAME;

程序猿必读

Mysql执行Update操作时会锁住表的更多相关文章

  1. MySQL DROP TABLE操作以及 DROP 大表时的注意事项【转】

    删表 DROP TABLE Syntax DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ... [RESTRICT | CASCAD ...

  2. MySQL的中的全局锁、表级锁、行锁

    MySQL的中的全局锁.表级锁.行锁 学习极客时间-林晓彬老师-MySQL实战45讲 学习整理 全局锁 对整个数据库实例加锁.通过使用Flush tables with read lock (FTWR ...

  3. mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY

    mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY 今天开发的同事发来如下错误信息,最最简 ...

  4. mysql执行update报错1175解决方法

    mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...

  5. 利用sqoop对mysql执行DML操作

    业务背景 利用Sqoop对MySQL进行查询.添加.删除等操作. 业务实现 select操作: sqoop eval \ --connect jdbc:mysql://127.0.0.1:3306/m ...

  6. svn执行update操作后出现:Error : Previous operation has not finished; run 'cleanup' if it was interrupted.

    svn执行update操作后出现:      Error : Previous operation has not finished; run 'cleanup' if it was interrup ...

  7. mysql批量update操作时出现锁表

    https://www.cnblogs.com/wodebudong/articles/7976474.html 最近遇到一件锁表的情况,发现更新的语句where检索的字段,没有建索引,且是批量操作的 ...

  8. 详述 MySQL 中的行级锁、表级锁和页级锁

    转自:https://blog.csdn.net/qq_35246620/article/details/69943011 refer:cnblogs.com/f-ck-need-u/p/899547 ...

  9. mysql执行update语句受影响行数是0

    mybatis连接mysql数据库,发现同一个update执行多次,返回的int值都是1. 我记得同样的update再次执行时 受影响行数是0. 后来发现,我之前一直用的SQLyog是这样子的. 原来 ...

随机推荐

  1. CUBRID学习笔记 12防火墙设置 linux

    这玩意是linux上用的. 如果你的数据库不是装在linux下可以飘过了 iptables -I INPUT -p tcp --dport 8001 -j ACCEPT iptables -I INP ...

  2. SLAM reference

    Technical website: OpenSlam: http://openslam.org/ MRPT: http://www.mrpt.org/ Monocular SLAM: https:/ ...

  3. Codeforces Round #279 (Div. 2) E. Restoring Increasing Sequence 二分

    E. Restoring Increasing Sequence time limit per test 1 second memory limit per test 256 megabytes in ...

  4. phpStorm快捷键

    1.快速寻找方法,变量定义处:ctrl + b或者ctrl+单击 2. 移动视图,方便快捷的移动代码窗口: ctrl + up, down 3. 代码方法间快速跳转:alt + up, down

  5. 表单美化-原生javascript和jQuery单选按钮(兼容IE6)

    最近很多人问怎么美化表单的元素,大家都知道表单元素在各个浏览器中的表现不一,反正也是特别的丑,那么问题就来了,我们能自己设计表单元素的外观么?答案是可以的,现在我们就来试试吧.我们用两种方式来实现这一 ...

  6. HTML5探索之datalist研究

    最近一个项目需要用到类似淘宝,百度搜索时的自动检索方案.自然想到了使用datalist标签.但是遇到一个bug,经过两天研究.小有结果给大家分享下~~ 首先看bug吧!~ 因为项目最开始测试就是用36 ...

  7. JavaWeb学习总结(四)—ServletConfig和ServletContext

    一.ServletConfig 1. ServletConfig介绍: ServletConfig是Servlet中的init()方法的参数类型,服务器会在调用init()方法时传递ServletCo ...

  8. Wincap安装出现“error opening file for writing wpcap.dll”之解决办法

    Wincap安装出现"error opening file for writing wpcap.dll"之解决办法 安装Wireshark时,一直出现下面的错误,选择忽略这个错误, ...

  9. Ubuntu系统下面软件安装更新命令

    在ubuntu服务器下安装包的时候,经常会用到sudo apt-get install 包名 或 sudo pip install 包名,那么两者有什么区别呢? 1.区别 pip用来安装来自PyPI( ...

  10. Echarts柱形图颜色设置

    ECharts图为每个数据项配置颜色 (2014-11-12 15:52:53) 转载▼ 标签: 时尚 分类: 开发学习 其实给每个数据项配置很简单 只需要在series里面给data数组的每个元素设 ...