Oracle 大批量更新数据方法(游标)


场景:要批量修改某张表某个字段的数据,大概1万多吧,一执行更新就卡死,找到这种办法耗时比较短:

BEGIN

FOR cur IN (

--此处写要更新数据的范围
select t.*, t.rowid from mstdata.md_product_structure_ext t
inner join mstdata.md_product_structure tm on t.md_product_structure_ext_id = tm.product_structure_ext_id
where tm.version = 1034 and tm.hierarchy_level = 3
) loop

--更新内容
update mstdata.md_product_structure_ext t set t.vehicle_mold = 'SUV,MPV' where t.md_product_structure_ext_id = cur.md_product_structure_ext_id;--
END loop;
END;

游标法,真香!


免责声明!

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



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