sqlplus中批量更新多条记录

来源:百度知道 编辑:UC知道 时间:2024/06/17 04:14:22
需要用sql语句实现批量更新多条记录
效果类似
update tab_a set a1 =(select a1 from tab_b where id = 'id1')
a2 =(select a2 from tab_b where id = 'id1')
...
an =(select an from tab_b where id = 'id1')
where id ='id1'
...

update tab_a set a1 =(select a1 from tab_b where id = 'idn')
a2 =(select a2 from tab_b where id = 'idn')
...
an =(select an from tab_b where id = 'idn')
where id ='idn'

有谁知道的,帮忙写下,谢谢了

update tab_a set a1 a =(select a1 from tab_b b where id = a.id)
a2 =(select a2 from tab_b where id = a.id)
...
an =(select an from tab_b where id = a.id)
where a.id ='id1' or a.id ='idn'

update tab_a set tab_a.a1=b.a1, tab_a.a2=b.a2, tab_a.a3=b.a3
from tab_b b
where tab_a.id=b.id

在每条语句的后面加分号,作成.sql脚本在SQLPLUS中执行
例:update tab_a set a1 =(select a1 from tab_b where id = 'id1')
a2 =(select a2 from tab_b where id = 'id1');