Create Datastore Scripts for Db2

You can choose to have databases created dynamically like SQL Server and PostgreSQL, but because Db2 database creation can be very slow, we recommended that you create them ahead of time using SQL scripts.

  1. To create the database script file, on the command line, enter the following command:
    dbfhadmin -script -type:datastore -provider:db2 -name:<datastore-name> -file:<script-name.sql> [-existdb:<db-name>|-db:<db-name>]

    where <datastore-name> must be 8 characters or less (a Db2 restriction), and where <script-name.sql> is the name of the script file to be created.

    Additionally, there are two (mutually exclusive) optional parameters that you can specify: if you are creating the datastore to be within an existing Db2 database (for example, you may have one database that holds all datastores, region databases, and a cross-region database), use the -existdb option; if you are creating a new Db2 database for the datastore, use the -db option to specify the name of the database; if you omit both options, a new database with a default name will be created - the default name is the value given for the -name option.

    Note: If you omit the -file option, the default name is create_dstore_<datastore-name>_db2.sql
    Tip: By default, Db2 databases are created with the SYSTEM_1252_US collating sequence on Windows, and SYSTEM_923_US on Linux/UNIX. Use the -collation attribute to specify an alternative collating sequence: see The dbfhadmin Command Line Utility for more details.
  2. Create further script files for any more required datastores.

    Once you have created the script files, use the dbfhadmin utility to run them, and create the required databases.

  3. To create the database, on the command line, enter the following command:
    dbfhadmin -createdb -file:<script-name.sql> -type:datastore -provider:db2

    where <script-name.sql> is the name of the script file that was created in an earlier step.

Next, you must create or edit a configuration file, so that it contains entries to the datastore databases.