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

类似于以下的情形:updatetablesetrest_left='13'whereid='1996'updatetablesetrest_left='15'wherei... 类似于以下的情形:
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串,求更高效的写法
展开
 我来答
badkano
2013-07-24 · 知道合伙人体育行家
badkano
知道合伙人体育行家
采纳数:144771 获赞数:885384
团长

向TA提问 私信TA
展开全部

没什么太高效的方法,除了你这样,就只能写成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;

其实两句都一样

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式