美文网首页
oracel数据处理

oracel数据处理

作者: youpd | 来源:发表于2019-10-08 09:38 被阅读0次

删除大量数据,避免大事务
DECLARE
i number;
allcount number;
BEGIN
i := 0;
select ceil(count(*) / 100) into allcount from ops_rank_bak;
WHILE i < allcount LOOP
i := i + 1;
delete from ops_rank_bak where rownum <= 100;
commit;
END LOOP;
commit;
END;

游标移动历史数据 每5000条提交一次。
declare
cursor cur is
select t.* from ops_test t where t.id > 6;
i number;
begin
i := 0;
for item in cur loop
merge into ops_test_history target using (select item.id as id,item.create_time as create_time from dual) sources on (sources.id=target.id)
when matched then
update set target.create_time=sources.create_time
when not matched then
insert (target.id,target.create_time)values (sources.id,sources.create_time);
delete from ops_test where id = item.id;
i := i + 1;
if (i >= 5000) then
commit;
i := 0;
end if;
end loop;
commit;
end;

创建带参数的存储过程
create or replace procedure clear_ops_kpi_d(from_file_name IN ops_kpi_d.from_file_name%type) as
begin
declare
cursor cur is
select id from ops_kpi_d where FROM_FILE_NAME = from_file_name;
i number;
begin
i := 0;
for item in cur loop
delete from ops_kpi_d where id = item.id;
i := i + 1;
if (i >= 5000) then
commit;
i := 0;
end if;
end loop;
commit;
end;
end;

调用存储过程:
call CLEAR_OPS_KPI_D('CHAN_KPI_D_[20190917].DAT')
DECLARE
i number;
allcount number;
BEGIN
i:= 0;
select ceil(count(*) / 100) into allcount from ops_rank_bak;
WHILE i < allcount LOOP
i:= i + 1;
delete from ops_rank_bak where rownum <= 100;
commit;
END LOOP;
commit;
END;

相关文章

  • oracel数据处理

    删除大量数据,避免大事务DECLAREi number;allcount number;BEGINi...

  • Oracel

    oracel一次查询多个sequence,批量查询sequence oracel批量插入-先批量获取sequenc...

  • oracel

    统计百分比: select sum(t1.reward_money) as reward_money, t...

  • oracel管理

    对于Oracle数据库有了一定的了解,已经基本满足Oracle的日常开发工作。但是在实际当中我们一般需要一个懂得管...

  • Servlet中调用数据库

    Oracel ResultSet rs = ps.executeQuery(); while(rs.next())...

  • 分页sql语句

    选择4-6的条数 t是表的别名 oracel select * from(select t.* , rownum ...

  • Oracel_子查询

    SQL子查询 子查询语法 子查询 (内查询) 在主查询之前一次执行完成。 子查询的结果被主查询(外查询)使用 。 ...

  • oracel练习题

    查询20部门的所有员工信息。select * from emp where deptno='20'; 查询所有工种...

  • 二、ORACLE 数据类型

    2、ORACEL 数据类型 对应NUMBER类型的事例: NUMBER类型 对于日起类型,可以使用sysdate内...

  • python3 dataframe写入oracle数据库,监听

    背景:工作需要,将excel文件写入到oracel数据库中。目标:连接oracle,批量写入数据。 1、连接ora...

网友评论

      本文标题:oracel数据处理

      本文链接:https://www.haomeiwen.com/subject/tcovpctx.html