如下一个两表更新语句
UPDATE hzxm201610 a,xmhzylb1201610 b SET a.gk07_1_6=b.gk04_11,a.gk07_2_6=b.f06_1,a.gk07_3_6=b.f07_1,a.gk07_4_6=b.f08_1 where substring(a.gk01,1,4) in ('5323') and a.gk01=b.gk01 and dqdm='532300'
如果漏掉了where会怎么样:
UPDATE hzxm201610 a,xmhzylb1201610 b SET a.gk07_1_6=b.gk04_11,a.gk07_2_6=b.f06_1,a.gk07_3_6=b.f07_1,a.gk07_4_6=b.f08_1 substring(a.gk01,1,4) in ('5323') and a.gk01=b.gk01 and dqdm='532300'
一般以为是会报错。其实不然,这个语句正常执行!而且对两个表全扫描,最后什么也不做!但是会锁定两个表很长时间,导致应用系统无法工作!
查询mysql死锁的语句:
#Show PROCESSLIST;
SELECT * FROM information_schema.INNODB_TRX;
SELECT * FROM information_schema.INNODB_LOCKS;
SELECT * FROM information_schema.INNODB_LOCK_WAITS;
SHOW VARIABLES LIKE '%lock%';