快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

批量操作

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://6mz.cn/article/ipggoh.html

其他资讯