资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

批量操作

oracle:
declare
v_num number(8):=0;
BEGIN
FOR i IN (select id from T_BRAND ) LOOP
delete from T_BRAND de where de.id = i.ID;
v_num := v_num+1;
if v_num >=500
then
v_num :=1;
commit;
end if;
END LOOP;
END;

创新互联是专业的双城网站建设公司,双城接单;提供成都做网站、网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行双城网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

mongo:
for (i=0;i<1000000;i++){
db.users.insert(
{
"i":i,
"username":"user"+i,
"age":Math.floor(Math.random()*120),
"create":new Date()
}
);
}

MySQL:
DELIMITER $$
DROP PROCEDURE IF EXISTS prc_insert $$
CREATE PROCEDURE prc_insert ()
BEGIN
set @v_n=1;
while @v_n<1000
do
insert into t(name) values (@v_n);
set @v_n=@v_n+1;
END while ;

END $$

DROP PROCEDURE IF EXISTS prc_delete_aa;

CREATE DEFINER = root@% PROCEDURE prc_delete_aa()
BEGIN
DECLARE v_err int DEFAULT 1;
DECLARE v_P_POLICYINFO_ID VARCHAR(50);
DECLARE done int;
DECLARE v_count INT DEFAULT 0;
DECLARE cur_aa CURSOR for select P_POLICYINFO_ID from aa;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET v_err=0;
START TRANSACTION;

OPEN cur_aa;
posLoop:LOOP
IF done=1 THEN
LEAVE posLoop;
END IF;
FETCH cur_aa into v_P_POLICYINFO_ID;
insert into bb select * from aa where aa.P_POLICYINFO_ID = v_P_POLICYINFO_ID;
delete from aa where P_POLICYINFO_ID = v_P_POLICYINFO_ID;
SET v_count = v_count + 1;
IF v_err=0 THEN
ROLLBACK;
ELSE
IF v_count = 1000 THEN
COMMIT;
SET v_count = 0;
END IF;
END IF;
END LOOP posLoop;
commit;
close cur_aa;

end;


本文题目:批量操作
网站URL:http://cdkjz.cn/article/ipggoh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220