Oracle update 一张表内更新多行数据的优化问题

类似于以下的情形:
update table set rest_left='13' where id='1996'
update table set rest_left='15' where id='1997'
update table set rest_left='13' where id='1998'
数据量有1W多,可以拿到更新的的id串和rest_left串,求更高效的写法

没什么太高效的方法,除了你这样,就只能写成case when或者decode的形式

update table set rest_left=decode(id,'1996','13','1997','15','1998','13',rest_left)

或者

update table set rest_left=case when id='1996' then '13'
                                when id='1997' then '15'
                                when id='1998' then '13'
                           else rest_left end;

其实两句都一样

温馨提示:答案为网友推荐,仅供参考
相似回答