oragen-0.1, oracle table data generator

Usage Overview

Overview

Oragen is a C program that generates random data or unique keys for an Oracle database table based on how you define the columns in the table It's purpose is for generating dummy data for the use of testing queries, pl/sql, tuning or for whatever other reason you can think of. Oragen generates the DML(insert) statement that inserts the data into the table and optionally the DDL(create table) statement that creates the table before the insert. Only varchar2 and number columns are supported.

(NOTE: it is anticipated that in a future release the date column will be supported and a GUI frontend)

Please let me know what you think, email stelliosk@optushome.com.au


download

Examples of Usage

  • examples

    Usage overview


    USAGE: oragen --table-name tablename --rows [--gen-table] [--commit number] [--help] [--Verbose] [--unique | --Null percentage] [--length number] [--cangrow] [--lowercase] [--alpha] [--v-number] [--punctual] [--number number] [--varchar2] < [--column-name name] | [--column] > OPTIONS -h --help display this screen -V --Verbose display Verbose information -g --gen-table generate table creation script -t --table-name table name for DML statement -r --rows number of rows to generate statement for -T --commit commit after so many insert statements -------------- column specific options ------------- -u --unique unique key column, won't repeat data -N --Null percentage of column to be left as Null. Ignored if unique is set -L --length length of varchar2 or max size of number -l --lowercase all alpha characters in lowercase -C --cangrow for varchar2 will vary on size from 1 to length in size -v --varchar2 generate as varchar2 -a --alpha generate varchar2 as alphanumeric characters -m --v-number generate varchar2 as number only -n --number generate as number -p --punctual generate punctuation also, can't be used with unique key -C --column-name user specified column name -c --column program generated column name Usage options overview non column specific options --help [-h] displays the help screen --Verbose [-v] displays verbose information, to stderr! this way when you redirect the output you don't get the verbose information in the script and you can see what is happening. Alternatively you can redirect stderr to stdout and include the verbose output by ./oragen .... 2>&1 > myscript.sql # redirect stderr to stdout all verbose lines being with comment( -- ) and will be ignored --gen-table [-g] generate a table creation script The table will be created before any data is inserted into the table (well obviously) in the default Tablespace. All other default create table parameters set in your schema will be used for example, initial and next extents, so be careful when generating data for a large table. Edit the script prior to running it if you have to or you could get extent problems. NOTE: this will also drop the table before creating it. --table-name [-t] table_name name of the table to insert data into or create table script for --rows [-r] number number of rows to generate --commit [-c] number commit after this many rows Column specific options --unique [-u] Ensures that the data in this column will be unique. This is done so by using a counter based key so the next key will always be greater than the last key. If for a column the number rows is more than the number of unique keys that can be generated, then the program will display an error message and not generate anymore insert statements, commit and exit. --Null [-N] number NOTE: number must be in the range 1 - 99 If a row in not unique and this option is specified, then approximately this percentage of rows that are generated for this column will contain a NULL value. It will not neccesarily be always the percentage you specify precislely, the NULL is determined by generating a random number between 1 and 99 and generating a NULL if it is less than or equal to your number. You can see how many NULLs where generated for your column by doing select COLUMN_NAME from TABLE_NAME where COLUMN_NAMEn is null; and the percentage of NULLs for the column by select b.count/a.max "percentage of column is null" from (select max(rownum) max from TABLE_NAME) a, (select count(*) count from TABLE_NAME where COLUMN_NAME is null) b; if you do specify this option for a unique column it will be ignored --length [-L] number This specifies the length of a varchar2 or the maximum number that a number can be --lowercase [-l] This makes all alphabetic characters in lowercase, for varchar2 --cangrow [-C] This will make the varchar2 column vary in size from 1 to it's --length in size, and for number will generate a number from 1 to --length in max size This option cannot be used with the --unique option. --varchar2 [-v] generate a varchar2 column, if you don't specify it's size with a --length option then the default length is used NOTE: a varchar2 cannot be greater than 4000, see the Internal Datatype representation of Oracle --alpha [-a] generate varchar2 as alphanumeric characters --v-number [-m] generate varchar2 as numbers only, no characters --number [-n] generate a number column, if the generate table option is also specified then the precision for the column is calculated by how many times the number is divisible by 10 --punctual [-p] include punctuation characters also in the varchar2, can't be used with unique key IMPORTANT: the next 2 options delimit the column, either must be specified to end the current column so you can move onto defining the next one, if none are specified then no data will be generated --column-name [-C] name_of_column this specifies the name of the column to insert data for --column [-c] program generated column name, of the form "col1.. col2" etc Default program options ----------------------- You can change the default program options by editing the file oragen.h and changing the values for the #define statements and then recompile. NOTE be careful what your doing, you can see the values for the column you've defined with the -V option which also displays the defaults

    oragen main index