Generate a database script from meta-schema

Generate a 4gl source file to be used to create or update a database that is described in the meta-schema file.

  1. Right-click on the meta-schema file in the project.
  2. Select an option:
    • Generate Database Creation Script to generate a source 4gl file that can be used to create a new database and tables according to the meta-schema file.
      Note:

      Database views are not included in the generated file.

    • Generate Database Update Script to generate a source 4gl file that can be used to update an existing database based on the meta-schema file.
      Note:

      The database update script will first drop the existing tables including their data, and then recreate the structure of the database based on the modified schema. Previous versions of the tables will be backed up and the data will be migrated to the new tables when applicable. It is recommended to perform a backup of the database prior to running the update script.

  3. Complete the Generate Database Script dialog.
    Figure: Generate Database Script dialog

    Screen shot of Database Generation Script dialog.
    Database schema
    Name of selected meta-schema file.
    Target database
    Specify the database to use in the script.
    Generate primary keys, secondary keys, indexes
    Specify whether to include primary keys, secondary keys, and indexes in the script.
    Use national char types
    By default, the database creation / update scripts will generate column using standard char types. If this option is set, the scripts will produce columns using national char types. For example, with an Oracle® database, the column types will be CHAR or VARCHAR2 when the option is not selected, and NCHAR, NVARCHAR2 when the option is selected.
    Populate database with sample data
    Add statements in the script to add sample data to the database.
    Note:

    This sample data comes from the Studio Libraries. If populating the database does not work (for example, you might have changed to an older version of FGL), try recompiling the Studio Libraries.

    Drop backup tables
    The database creation / update scripts will create backup tables for tables updated by the script. If this option is set, the backup tables are deleted when the script has finished executing and the tables are updated.
  4. Select Generate.