您好,登錄后才能下訂單哦!
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;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。