存储过程批量更新表
发布时间
阅读量:
阅读量
近期处理了一个需求,需要对数据库表进行批量数据更新操作,但由于涉及的数据量较大(达到千万级别),若直接采用SQL语句进行更新,可能会导致PL/SQL环境出现崩溃的情况。
所使用的SQL语句如下:update product set online_flag = '0' where status = 'ON'
因此,编写了一个存储过程以供后续参考:
declare
cursor product_id_list is
select product_id
from product
where status = 'ON';
commit_count number := 0;
total_count number := 0;
begin
for pid in product_id_list loop
total_count := total_count + 1;
commit_count := commit_count + 1;
update product
set online_flag = '0'
where status = 'ON
全部评论 (0)
还没有任何评论哟~
