在寫儲存過批量插入資料

2021-10-07 23:35:51 字數 738 閱讀 9929

1、編寫儲存過程

delimiter $$                              #以delimiter來標記用$表示儲存過程結束

create procedure pre()           #建立pre()儲存方法

begin                

declare i bigint;                          # 定義i變數

set i=8986061900004332057;                                # 定義插入資料預設值

while i<8986061900004332306 do                           # 定義插入資料最大值

insert into tencent_collector.tencent_sim(iccid,iccid_type,remark) values (i,1,"聯通");

set i=i+1;

end while;

end$$

2、call pre(); # 執行儲存過程

3、#查詢儲存過程執行結果

select * from tencent_collector.tencent_sim where iccid between "8986061900004332056" and"8986061900004332306";

4、#刪除儲存過程

drop procedure pre;

MySql批量插入資料 儲存過程

批量插入儲存過程 create procedure auto insert in indexs int,in loops int begin declare v sql longtext set v sql insert into t info name,time values while inde...

mysql利用儲存過程批量插入資料

最近需要測試一下mysql單錶資料達到1000w條以上時增刪改查的效能。由於沒有現成的資料,因此自己構造,本文只是例項,以及簡單的介紹。首先當然是建表 create table fortest id int 30 unsigned not null auto increment primary ke...

批量插入資料

drop procedure if exists pre 如果存在先刪除 delimiter 以delimiter來標記用 表示儲存過程結束 create procedure pre 建立pre 儲存方法 begin declare i int default 12 declare n int de...