I want to test some schemas and indexes, and I was wondering if there is a functionality in PL/SQL Developer that can generate test data (so I won't have to create sequences and loops to insert data in the tables).
Asked
Active
Viewed 1.6k times
9
-
I don't believe there is I'm afraid. – Chris Oct 16 '13 at 08:47
-
http://www.orafaq.com/wiki/Oracle_Row_Generator_Techniques – Vadzim May 23 '18 at 09:08
-
AskTom: https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2151576678914 – Vadzim May 23 '18 at 09:08
1 Answers
23
Loops and PL/SQL aren't always necessary; this trick might be helpful:
insert into emp(id, name, salary)
select rownum, 'Employee ' || to_char(rownum), dbms_random.value(2, 9) * 1000
from dual
connect by level <= 100;
will generate 100 records, named Employee 1 through Employee 100 with random "round" salaries between 2000 and 9000.
The two main techniques are:
- Use of
connect by level <= n
to generate n rows in a query on dual. - Use of
dbms_random
package; there's also a very useful functiondbms_random.string
which can be used -- like its name suggests -- to generate random strings of a certain length containing certain characters.

dfa
- 114,442
- 31
- 189
- 228

Colin 't Hart
- 7,372
- 3
- 28
- 51