Many times need create a tables, normally for testcases porpouses, with random data sets. Create those datas look easy, but it depends on we need. Usually you’ll create data sets in way similar to this;
DB12> create table tab1 (data number);
Tabla creada.
DB12> insert into tab1 select level from dual connect by level <= 10;
10 filas creadas.
DB12> select count (*) from tab1;
COUNT(*)
__________
10
Okay, it is correct but this create a uniform distribution. As I said before, sometimes we will need data sets with specific data distributions, especially to play with the histograms when manipulating the statistics. Oracle only include the normal distribution, maybe later to take other types of distributions, such as logarithmic, included in the engine, so you can implement by programming, Java is a good option.
Let’s look at the example to call the normal distribution;
DB12> declare
2 begin
3 for i IN 1..10 LOOP
4 dbms_output.put_line (trunc (dbms_random.value (1,10)));
5 END LOOP;
6 END;
7 /
3
2
7
4
8
7
1
7
4
6
In this example we have generated ten numbers, between 1 and 10, with normal distribution.
HTH – Antonio NAVARRO