oracle 分批提取数据,Oracle批量insert造数据和分批提交删除的例子

批量insert造数据和分批提交删除的例子

create or replace procedure myj_insert(maxrecords in number :=100) is

i number :=1

begin

for i in 1..a

loop

Insert into ADZONES

(ADZONEID, NAME, FORMAT, TRANSTYPE, SIZECODE, ADZONESIZE, WEEKPRICE, CANSELLTIME, CREATETIME, UPDATETIME, STATUS, MEMBERID, SITEID, SITENAME, SITEURL, KEYWORDS, PROPERTIES, ADZONECATIDS, NEEDAUDITING, MARKS, EDITED, ISBUSY, CPMPRICE, CPMSTATUS, SNAPSHOTTIME, DISTYPE)

Values

(101514, '全站内页200*200', '3', '7', '32', '250x300', 500, TO_DATE('08/31/2007 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2007 10:56:26', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2007 10:56:26', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10001461, 100975, '屁屁视频', '', '娱乐', '{"sex":["1","多数是男的"],"income":["2","1000~3000"],"age":["2","18~25岁"],"hobby":"","job":["1,2,6,7","学生,职员,自由职业者,待业者"]}', '39999', '1', '0', '0', 1, 0.8, '0', TO_DATE('12/06/2007 17:21:19', 'MM/DD/YYYY HH24:MI:SS'), '1');

end loop;

commit;

dbms_output.put_line(maxrecords||' insert done');

end myj_insert;

/

create or replace procedure delBigTab

--分批提交删除

(

p_TableName in varchar2,--表名

p_Condition in varchar2,--条件

p_Count in varchar2--每批提交的条数

)

as

pragma autonomous_transaction;

n_delete number:=0;

begin

while 1=1 loop

EXECUTE IMMEDIATE

'delete from '||p_TableName||' where '||p_Condition||' and rownum <= :rn'

USING p_Count;

if SQL%NOTFOUND then

exit;

else

n_delete:=n_delete + SQL%ROWCOUNT;

end if;

commit;

end loop;

commit;

DBMS_OUTPUT.PUT_LINE('Finished!');

DBMS_OUTPUT.PUT_LINE('Totally '||to_char(n_delete)||' records deleted!');

end;

/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值