你的语句都写的有问题,当然没有反应了,请把update的字查询加入限定。具体应用这样吧
Update T_TEMP_STOCKCTRL set FSALEQTY0 = (
select sum(ogb12)
from oga_file ,ogb_file ,ima_file
where oga01 = ogb01 and ogb04 = ima01
and substr(ogb09,0,5) = fwhno
and ima140 = fbrand and ima02 = fgrade
and T_TEMP_STOCKCTRL.ima140=ima140 and ima02 = T_TEMP_STOCKCTRL.ima02 and ... )
也就是对于T_TEMP_STOCKCTRL的每一行都需要从子查询中查出相应的记录
Update T_TEMP_STOCKCTRL set FSALEQTY0 = (
select sum(ogb12)
from oga_file ,ogb_file ,ima_file
where oga01 = ogb01 and ogb04 = ima01
and substr(ogb09,0,5) = fwhno
and ima140 = fbrand and ima02 = fgrade
and T_TEMP_STOCKCTRL.ima140=ima140 and ima02 = T_TEMP_STOCKCTRL.ima02 and ... )
也就是对于T_TEMP_STOCKCTRL的每一行都需要从子查询中查出相应的记录
Update T_TEMP_STOCKCTRL set FSALEQTY0 = (
select sum(ogb12)
from oga_file aa ,ogb_file bb ,ima_file cc
where aa.oga01 = bb.ogb01 and bb.ogb04 = cc.ima01
and substr(bb.ogb09,0,5) = T_TEMP_STOCKCTRL.fwhno
and cc.ima140 = T_TEMP_STOCKCTRL.fbrand and cc.ima02 = T_TEMP_STOCKCTRL.fgrade
Group by cc.ima140, cc.ima02 , substr(bb.ogb09,0,5) )
跟你说的一样啊,没有放应可能是速度奇慢,但是对应的查询只需要3秒种。请问两个SQL语句不一样吗?Update语句有错误吗?谢谢拉。
from oga_file aa ,ogb_file bb ,ima_file cc , T_TEMP_STOCKCTRL
where aa.oga01 = bb.ogb01 and bb.ogb04 = cc.ima01
and substr(bb.ogb09,0,5) = T_TEMP_STOCKCTRL.fwhno
and cc.ima140 = T_TEMP_STOCKCTRL.fbrand and cc.ima02 = T_TEMP_STOCKCTRL.fgrade
Group by cc.ima140, cc.ima02 , substr(bb.ogb09,0,5)
这个速度很快,只要3秒,如何优化Update语句?谢谢
update进行小量数据的处理还可以..
大一点的数据就与一般查询很明显的有差别,这时可以考虑生成新的表,或者你把系统的缓冲区加大,让命中率能达到99%,这样update 就会快一些.
不知道一条SQL能够达到上面的效果?据说用Exist可以,哪位高手能解决?