Generating Test Data to a Database

PowerDesigner can generate sample data to your database tables to verify performance or to help in estimating the amount of memory that the database will require. You can generate test data for some or all of the tables in your PDM to an empty or existing database.

Note: The following objects are not taken into account when you generate test data:
  • Alternate keys

  • Foreign keys

  • Business and validation rules

  • Binary, sequential, OLE, text or image data types

  • Trigger contents

  1. [optional] Specify one or more test data profiles to define the range of data to be generated or to draw data from a file or other database (see Populating Columns with Test Data). If you do not define profiles, PowerDesigner will generate random data that is appropriate to each data type.
    Note: The format in which date and time data is generated with or without profiles can be controlled by DBMS items in the Script/Sql/Format category (see Customizing and Extending PowerDesigner > DBMS Definition Files > Script/Sql Category.
  2. Select Database > Generate Test Data to open the Test Data Generation dialog.
  3. On the General tab, enter or select the appropriate parameters:
    Option Description

    Directory

    Specifies the directory in which the file will be saved.

    File name

    Specifies the name of the test data file to generate. Select the One file only checkbox to specify that a single file should be generated.

    Generation type

    Specifies how the test data will be generated:
    • Script generation
    • Direct generation – to a live database connection.
      Note: As triggers are not needed in this context and can block insertions and considerably increase the time required to generate the database, we recommend that you do not implement triggers or remove them from your test database.
    • Data file – as a set of values in a file.

    Commit mode

    Specifies when the data will be committed:
    • Auto - during script generation

    • At end - after script generation

    • By packet - at defined intervals during script generation

    Data file format

    Specifies the format when generating a data file:
    • CSV – comma-separated values

    • Custom delimiter – specify a custom delimiter

    Delete old data

    Deletes existing data before generating new data.

    Check model

    Checks the PDM before generating the test database or script, and stops generation if an error is found.

    Automatic archive

    Creates an archive of any previous test data.

    Default number of rows

    Specifies the default number of rows to generate for tables. This number can be overrridden for individual tables on the Number of Rows tab.

    Default number/ character/ date profile

    Specifies the default test data profiles (see Populating Columns with Test Data) to use to generate data. We recommend that you create test data profiles to accurately model your data and associate them with each of your columns and domains as appropriate, but if you have not done so, then these default profiles are used.

  4. [optional] Click the Number of Rows tab to change the number of rows to be generated for each table.
    By default, PowerDesigner generates the number of rows that is specified in the Number property in the table property sheet (see Table Properties) or, if no number is specified, the default number specified on the General tab of this Test Data Generation dialog.
  5. [optional] Click the Format tab and modify the script formatting options as appropriate:

    Option

    Result of selection

    Owner prefix

    Specifies that an owner prefix is added.

    Titles

    Specifies that each section of the script includes commentary in the form of titles.

    Encoding

    Specifies the encoding format to use for test data generation. You should select the encoding format that supports the language used in your model and the database encoding format.

    Character case

    Specifies the character case to use. The following settings are available:

    • Upper - all uppercase characters

    • Lower - all lowercase characters

    • Mixed - both uppercase and lowercase characters

    No accent

    Non-accented characters replace accented characters in script.

  6. [optional] Click the Selection tab and select which tables you want to generate test data for. By default all tables are selected.
  7. Click OK to start the generation.

    If you are generating test data to a live database connection, then the Connect to a Data Source dialog box opens. Select a data source, and then click Connect. If you are generating a test data script, then a Result dialog box asks you if you want to Edit or Close the newly generated file.

    A message in the Output window indicates that the test data generation is completed.