【发布时间】:2017-10-04 10:50:11
【问题描述】:
我不太擅长 sql,我尝试了一些东西。考虑到代码的性能,将这 5 个更新语句组合成一个语句的最佳方法是什么?会有很大的帮助。非常感谢!
代码:
----------------1
Update main_table
set a = (case
..some code.. end)
where condition_2;
----------------2
Update main_table
set b = (case
..some code.. end)
where condition_2
----------------3
Update main_table
set c = (select x from sec_table where conditon_1)
where condition_2
----------------4
Update main_table
set d = (select y from sec_table where conditon_1)
where condition_2
----------------5
Update main_table
set e = (select z from sec_table where conditon_1)
where condition_2
【问题讨论】:
-
我已经尝试过了,但我正在寻找更好的性能:UPDATE main_table SET a = (CASE some code END), b = (CASE some code END), c = (SELECT x FROM sec_table WHERE condition_2), d = (SELECT y FROM sec_table WHERE condition_2), e = (SELECT z FROM sec_table WHERE condition_2) WHERE condition_1;
标签: sql oracle performance