温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

批量操作

发布时间:2020-07-25 19:10:59 来源:网络 阅读:166 作者:春秋小记 栏目:数据库

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;

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;

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI