Set up DB2

These instructions assume that you are using DB2 Universal Database and guide you through the following tasks:

Note. When you create and access the database tables, be aware of the following issues:

Complete the following steps:

  1. In a DB2 command window, enter the following command to ensure that DB2 is started:
    db2start
  2. Create a database called PATSDB.
  3. Open a new document in a text editor, copy and paste the following script, which connects to the PATSDB database and runs the BIND utility, into the document, name the file PATSDB.sql and save the file.
  4. In a DB2 command window, navigate to the folder that contains PATSDB.sql and enter the following command:
    db2 -vf PATSDB.sql
  5. Open a new document in a text editor, copy and paste the following script, which creates the PATIENTS table, into the document, name the file patients_create_tables_db2.sql and save the file.
    CONNECT TO PATSDB@
    DROP TABLE "PATIENTS"@
    CREATE TABLE "PATIENTS" (
        "DEVICEID" VARCHAR(50) NOT NULL PRIMARY KEY,
        "PATIENTID" VARCHAR(50)
    )
    DATA CAPTURE NONE@
    TERMINATE@
            
  6. Ensure the database is running and connected.
  7. Open a command window to access your database, move to the folder that contains patients_create_tables_db2.sql and enter the following command:
    db2 -td@ -vf patients_create_tables_db2.sql

    Wait for the script to finish running. If you are running the script for the first time, the following message is displayed:

    DB21034E  The command was processed as an SQL statement because it was not a
    valid Command Line Processor command.  During SQL processing it returned:
    SQL0204N  "DB2ADMIN.PATIENTS" is an undefined name.  SQLSTATE=42704
            
    Ignore this message. The message is displayed because the script attempts to remove the existing table, PATIENTS, before it creates the new table, but if you have not run the script before, the script cannot find the existing table.

Back to Setting up the patient identifier database