Oracle存储过程插入千万条记录测试
1、创建表
create table TEST_ORCL
(
id NUMBER(11) not null,
name VARCHAR2(50),
email VARCHAR2(50),
address VARCHAR2(50),
mobel_phone VARCHAR2(11),
mod_num NUMBER(5),
)
alter table TEST_ORCL add primary key (ID)
2、存储过程创建Sql
-- rowNum插入记录数
-- rowNumMax 数据表中Id最大数(number类型)
CREATE OR REPLACE PROCEDURE insertRowNumInfo(rowNum in number,rowNumMax in number) is
i number :=rowNumMax;
num number := rowNum + rowNumMax;
begin
-- 定义sql为loop;
loop
insert into test_orcl(id,name,email,address,mobel_phone,mod_num)
values (i,'name'||i,'email'||i||'@qq.com','address'||i,''||i,mod(i,9));
i :=i+1;
-- 循环条件
exit when i>num;
end loop;commit;
end;
3、执行存储过程插入千万条记录
(插入1000W条记录,从ID为1开始插入(1000W执行时间大概8min))
begin
insertrownuminfo(1000000,1);
end;