create or replace procedure generate_data(tbl_name varchar,min_value int, max_value int) is
MAX_NUM integer := max_value;
MIN_NUM integer := min_value;
tmp_val varchar2(100):='';
BEGIN
for i in MIN_NUM..MAX_NUM
loop
tmp_val:='u'||i;
execute immediate 'insert into '||tbl_name ||' values(:1, :2)' using i,tmp_val; --insert语句末尾不能有分号,否则出错
end loop;
commit;
END;
建表
create table test0(id int, name varchar2(100));
调用存储过程,生成数据
begin
generate_data('test0',1,10000000);
end;
新建其他表
create table test1 as select * from test0;
create table test2 as select * from test0;
create table test3 as select * from test0;
create table test4 as select * from test0;
create table test5 as select * from test0;
create table test6 as select * from test0;
create table test7 as select * from test0;
create table test8 as select * from test0;
create table test9 as select * from test0;