Oracle update set from where 批量update


--sql写法:
update bcd_samplingrecord_detail
set Invalid=t.cin,hasfilter=t.ch
from (select recordid cid,Invalid cin,hasfilter ch from bcd_samplingrecord) t
where recordid=t.cid

--Oracle写法:卡死人
update bcd_samplingrecord_detail t1
set (t1.Invalid,t1.hasfilter)=(select Invalid,hasfilter from bcd_samplingrecord t2 where t2.recordid=t1.recordid) 


--直接游标
begin
  for c in (select * from bcd_samplingrecord)
    loop
      update bcd_samplingrecord_detail 
      set Invalid=c.invalid,hasfilter=c.hasfilter
      where recordid=c.recordid;
    end loop;
end;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM