有时候做实验测试数据用到大量数据时可以用以下方法插入:
方法一:使用xmltable
create table bqh8 as select rownum as id from xmltable('1 to 10000000');
select count(*) from bqh8;
-----------------------一千万条数据已插入。
方法二:使用dual+connect by level
create table bqh9 as select rownum as id from dual connect by level
<=10000000;
select count(*) from bqh9;
使用connect by level有上限的,若超出上限,会报"ORA-30009:CONNECT BY 操作内存不足"
错误。
-------------一百万条数据已插入。
方法三:
create table bqh10 (A int,B char(50));
begin
for i in 1 .. 1000000
loop insert into bqh10 values (i,'NBA');
end loop;
commit;
end;
select count(*) from bqh10;
一百万条数据已插入,此方法插入比较慢。