• No results found

D ATA G ENERATOR

17. TOOLS

17.9 D ATA G ENERATOR

The data generator allows you to create demo and test data. This can be helpful to test applications and see how they perform with large amounts of data. You find the Data Generator under the Tools menu.

Basically, the definition consists of one or more tables, the number of records you want to generate, and the field data definitions. The buttons on the top left allow you to open and save a definition.

Above you see the supplied deptemp demo that creates data for deptdemo and empdemo tables, similar to the well-known dept and emp tables. You will find the following items on this page:

• Table – The name of the table.

• Number of records – The number of records you want to generate. This can be a number, but also a range like 10..100.

• Name – The field name.

• Type – The data type of the field.

• Size – The field size (when appropriate). For number fields this will be scale, precision.

• Data – The definition of the data for a field (see below).

• Master – If this table is the detail of another table, you can set the master. For every generated master record, the specified number of detail records are generated.

You can use the “Add existing table” button to add an existing table. You can also drag & drop one from the Object Bowser.

Data definition

The data definition determines the generated data. If you want to create simple characters, you can enter character definitions between square brackets: [data]

Data can be a mix of the following pre-defined sets:

a: a..z (lowercase characters)

A: A..Z (uppercase characters)

@: A..Z and a..z (all characters)

#: A..Z and a..z and 0..9 (all characters and numbers)

*: #33..#126 (all ASCII characters)

0: 0..9 (all numbers)

1: 1..9 (all numbers except 0)

9: 0..9 (all numbers)

For example:

[Aaa00] to generate strings like: Gxe21, Liy05, etc.

You can also add literal text between single quotes.

For example:

[AA '-' 1000] to generate strings like: CX-4903, SY-1044, etc.

Space characters in the definition are ignored, unless they are within quotes.

If you want a character repeated a number of times, you can add the number after the character between brackets (n). You can also add a random number (min..max).

For example:

[Aa(5..15) ' ' Aa(8..20)] for results like: "Masfae Qwwecdsadif"

Literal text in the definition does not have to be enclosed in brackets. In other words, ['hello'] and 'hello' are equivalent. Text entered without quotes is interpreted as a function.

The are several special functions available:

• Signal(Min, Max, Delta, Noise)

Returns technical measurement data (like temperatures). Min and Max determine the range, Delta the maximum change, and you can also add some noise. Example: Signal(-10, 20, 0.1, 0.1)

• Random([Min], Max)

Returns random numbers between Min and Max. If only Max is specified, Min is set to 0. For date fields you can enter dates for Min and Max.

• Sequence(Start, [Inc], [WithinParent])

Returns sequence numbers, starting with Start, and incrementing with Inc (which is 1 by default).

For a detail table you can additionally specify the WithinParent keyword to indicate that the sequence should be reset for each parent record.

• List('item'(weight), 'item'(weight), ...)

Returns randomly one of the specified items. A weight can be added between brackets to allow specific items to occur more often than others.

For example: List('CLERK'(50), 'SALESMAN'(30), 'MANAGER'(10))

• List(select statement)

Like the previous List function, but the items are returned by the SQL select statement.

• Text([Style], MaxCharacters, [WordsPerLine, LinesPerParagraph])

This function returns text. The optional Style parameter can be LorumIpsum (default), English, German or Japanese. It can also be a character set like [aA], in which case words are generated from the specified set.

MaxCharacters determines the maximum size of the generated text, and the optional

WordsPerLine, and LinesPerParagraph determine the size of a line and a paragraph. The specified size can be a number or a range (min..max).

• File(path, path, ...)

Randomly selects a file from the given paths, and inserts the contents. Allows you to enter binary data (like images) into the database. The path can have wildcards like d:\images\*.bmp.

You can change the text results of the previous functions by using the following functions:

• Uppercase()

• LowerCase()

• InitCaps()

For example: InitCaps( List(select ename from emp) )

There are also several predefined data sets available to generate more or less real data. You can use the following definitions:

• Firstname – General list of first names

• Lastname – General list of last names

• Company – Company names (random list of existing companies)

• Address1 – Address line 1

• Email (related to Firstname, Lastname and Country) There are also some example user-defined data sets available

• Components.Code – General article items: Article code

• Components.Description – Article description (Computer parts)

• Components.Price – Article price

• Elements.Name – Chemical elements (name)

• Elements.Symbol – Chemical elements (symbol)

These data sets can be found in the DataGenerator\UserData directory as elements.txt and

components.txt. You can add you own sets if you want. Simply add a comma-separated file where the first line holds the description between square brackets. You can use data from your file by specifying filename.description like the two examples.

All the functions and data mentioned above can be added together, for example: Random(10..99) + '-' + [A(4)]

The + is optional, but there should at least be a space as separator.

Options

The options tab page allows you to set some preferences specific to the data generator definition. You can specify a date format (as used for example by the Random function). You can also specify after how many records you want a commit (set to 0 to commit once when finished). The delay preference is only useful in some real-time testing where you want data inserted at a specific speed.

The “User Definitions” section allows you to define or override character sets used in the [data]

definition. The Item is always a single character, and the Value is one or more space separated ranges of characters like: A..Z a..z 0..9 #200..#220. For example: to define a hexadecimal character set, you could specify H as the item, and 0..9 A..F as the value.

The “Initialization Script” section allows you to specify SQL statements that should be executed before the data is inserted into the database. Typically, this would be a statement to create the tables, or to truncate the tables, to select a rollback segment, and so on. Multiple statements need to be separated by semicolons.

General options that will be used by default for all data generators can be defined by pressing the Preferences button on the left. See chapter 16.23 for more details. These preferences will be overruled if the corresponding preference in the data generator definition is also set.

Generating Data

There are three buttons available on the bottom left to generate the actual data:

Start a test run – This will generate the data and display the results in a grid on the Result tab page.

You can export these results in various formats by right-clicking on the grid.

• Create data as SQL – Generates the data as a SQL script. This will only work if you don’t add data from files with the file function.

• Create data in DB – Generates the data into the Oracle database.