Install this theme
Random test data generation in Oracle

There is nothing new or extraordinary in this statement.

Just a reminder for me to not dig around the Google next time I need this.

select level id,
       mod(rownum, 100) city_id,
       trunc(dbms_random.value(20, 60), 0) age,
       trunc(dbms_random.value(1000, 50000), 2) income,
       decode(round(dbms_random.value(1, 2)), 1, 'M', 2, 'F') gender,
       to_date(round(dbms_random.value(1, 28)) || '-' ||
               round(dbms_random.value(1, 12)) || '-' ||
               round(dbms_random.value(1900, 2010)),
               'DD-MM-YYYY') dob,
       dbms_random.string('x', dbms_random.value(10, 30)) address
  from dual
connect by level <= 1000;

Will generate 1000 rows of random data like this:

image
 
Blog comments powered by Disqus