Friday, June 02, 2006

Generate A Fixed Number Of Records

Generating a fixed number of records is very handy sometimes. It can be used to create a cartesian product with an other table if those records must get multiplied. Or just to generate test data.

Until I found this neat solution, I used to UNION-ALL selects from dual to multiply records and selects from large data dictionary tables to generate test data...

Here is the nice way:
select 'whatever I want '||level
from dual
connect by level <= 5
/

1 comment:

Anonymous said...

Simple and handy. As all of your tips!

Gruess
Chrigu