Create PostgreSQL Datastores Using Script Files

If a database does not exist at the point that it is required, it is created on-the-fly; this can be slow for certain RDBMS types, and so we recommended that you create any required databases 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:pg -name:<datastore-name> -file:<script-name.sql> 

    where <script-name.sql> is the name of the script file to be created.

    Note: If you omit the -file option, the default name is create_dstore_<datastore-name>_pg.sql.
  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. Before you run the -createdb command, ensure that the psql command is on the PATH.

  3. To create the database, on the command line, enter the following command:
    dbfhadmin -createdb -provider:pg -type:datastore -file:<script-name.sql> -user:<user> 
    where <script-name.sql> is the name of the script file that was created in an earlier step, and <user> is a valid user name for the database. It is also assumed that an entry for that user name has been created in the password file %APPDATA%\postgresql\pgpass.conf on Windows, or .pgpass in the user's home directory on Linux, in order to obtain the password. On Linux, PostgreSQL also supports the use of the PGPASSFILE environment variable to specify the location of the password file. Refer to your PostgreSQL documentation for more details.
Note: If you do not use script files for datastore creation, you can also create them using the dbfhdeploy data create URL/<datastore-name> command.

Now that the datastore has been created, you can start to upload data files to it using the dbfhdeploy command line utility.