Skip to content
Advertisement

Generating dynamic data using join select query in Oracle

We have a select query containing around 10 tables. using that query we are getting just 50 record. We need to get 50k record. actually we dont have functional understanding to generate data into these tables.

Is there any possibility, we can create insert query to insert data into these 10 table using that select query even if there is no integrity of data. We just need volume testing for the env.

Suppose I have below query

select d.deptno, d.dname,e.ename from dept d, emp e where d.deptno=e.deptno(+);

is there anyway to create insert query for emp and dept with little modification of data? I mean we can increase the id by one for primary key of the tables and generate thousands of records? is it possible?

I am just thinking if anything like this is possible.

Advertisement

Answer

You can generate a list of numbers and just repeat inserts. Assuming the primary key is automatically generated, you can generate however many numbers you want and just insert:

insert into emp ( . . . )
with n as (
      select level as n
      from dual
      connect by level + 1 < 100
     )
select . . .
from n;
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement