往oracle数据库表中插入五十万条数据

方法一:执行代码块

create table student2(id varchar2(20) primary key,name varchar2(20),birthdate date, age varchar2(10),phone varchar2(20),adress varchar2(32));
commit;

declare
i NUMBER;
begin
for i in 1..500000 loop
insert into student2(id,name,birthdate,age,phone,adress) values (i,'张三'||i,sysdate+1,'20','15811111111','北京');
commit;
end LOOP;
END;

select * from student2;
delete from student2 ;
commit;
--一分多钟74秒

方法二:

create table student3(id varchar2(20) primary key, name varchar2(20), birthdate date, age varchar2(20), phone varchar2(20), adress varchar2(20));
commit;

create or replace procedure insertdata
as
i NUMBER;
begin
for i in 1..500000 loop
    insert into student3(id, name, birthdate, age, phone, adress) values(i, 'mingtian', sysdate, '20','18830129153', '石家庄');
    commit;
    end loop;
end;

commit;

--declare执行存储过程
begin
insertdata;
end;

--48秒

原文地址:https://www.cnblogs.com/mingtian521/p/3396315.html