関連するテーブル (結合と参照整合性が必要な場合) の場合、pl/sql ブロックまたは一連の挿入を次々に作成する必要があります。
PL/SQL : --複数の行を生成する方法については、以下を参照してください...
Begin
for v_rec in (select level from dual
connect by level <= 1000)
loop
create_new_dept (v_rec.level);
create_1000_rows_for_dept(v_rec.level);
end loop;
end;
/
または SQL:
--create 1000 departments.
insert into dept(deptno, dname)
select level, 'deptno ' || level
from dual
connect by level <= 1000;
commit;
--create 1000 employees for each department..
with emp as
(select level empid
from dual
connect by level <=1000
)
insert into emp(empno, deptno, dname)
select deptno,
emp_seq.nextval,
'dname ' || 'emp ' || level empname
from dept,
emp; --no join condition, cartesian join on purpose
commit;
テーブルが互いに関連していない場合、2 つの一般的なアプローチがあります。
DBMS_RANDOM を使用して、クエリで接続し、複数の行を生成します。例...
--This will insert 1000 rows {(1, emp1), (2,emp2)} and so on..
insert into emp (empno, ename)
select level, 'employee ' || level
from emp
connect by level <=1000;
dba_objects のようなテーブルを使用し、複数の挿入を行ってデータを生成します。これは、「関数ベースのインデックスのパフォーマンス」のようなケースをテストしたい場合に役立ちます。データがたくさんある限り、それが何であるかはあまり気にしません。
create table my_test_table
as
select * from dba_objects; --or user_objects, all_objects
--keep doubling rows until you have enough rows.
insert into my_test_table
select * from my_test_table;
commit;