100万条数据,1分钟快速插入的方法(包含过滤,用于按号段增加)
1,创建一张表T_E_PROMOTION2USER
create table T_E_PROMOTION2USER
(
PROMOTIONID NUMBER(19) not null,
USERACCOUNT VARCHAR2(256) not null,
CREATETIME TIMESTAMP(6) WITH TIME ZONE default SYSDATE not null
);
alter table T_E_PROMOTION2USER
add constraint PK_T_E_PROMOTION2USER primary key (PROMOTIONID, USERACCOUNT);
2,创建一张表T_E_BATCHINSERT_SEQ
create table T_E_BATCHINSERT_SEQ
(
SEQ NUMBER(8) not null
);
alter table T_E_BATCHINSERT_SEQ
add constraint SEQ primary key (SEQ);
3,创建一个存储过程并向表中插入100万条数据
create or replace procedure batchinsert_seq www.zzzyk.com
is
i number(38);
begin
for i in 0 .. 999999 loop
insert into t_e_batchinsert_seq(seq) values(i);
end loop;
commit;
end batchinsert_seq;
/
call batchinsert_seq();
4,再向T_E_PROMOTION2USER这张表插入100万条数据
SQL语句如下:
insert into t_e_promotion2user(promotionid,useraccount,createtime)
select :promotionid, (:prefix || lpad(:endPhoneNum - seq,:length,'0')),sysdate
from t_e_batchinsert_seq where seq < :total
and (:prefix || lpad(:endPhoneNum - seq,:length,'0'))
not in (select userAccount from t_e_promotion2user where promotionId = :promotionid)
作者 jl292355621