Install IBM DB2 and create a database - database configuration/design tasks

If you are tasked with installing and configuring the database, here is a list of steps to be taken:

  1. Install the IBM® DB2® LUW on your database server.
  2. Create a DB2 database entity: dbname
    To create the database entity in DB2, use the db2 command interpreter in a DB2 operating system user session (db2inst).
    Note: Consider creating your database with the correct database locale (codeset and territory)
    For example:
    $ db2
    ...
    db2 => CREATE DATABASE dbname
              AUTOMATIC STORAGE YES
              USING CODESET UTF-8 TERRITORY EN_US
    DB20000I  The CREATE DATABASE command completed successfully.
  3. Connect to the new created database with the DB2 administrator user.
    Open a database connection as in the following example:
    db2 => connect to dbname
    
       Database Connection Information
    
     Database server        = DB2/LINUX 10.1.0
     SQL authorization ID   = DB2INST
     Local database alias   = dbname
  4. Declare a database user dedicated to your application: the application administrator. This user will manage the database schema of the application (all tables will be owned by it).
    Create the user as follows:
    db2 => GRANT CONNECT ON DATABASE TO USER appadmin
    DB20000I  The SQL command completed successfully.
  5. Give all requested database administrator privileges to the application administrator.
    Grant the privileges to create tables to the new created user as follows:
    db2 => GRANT CREATETAB ON DATABASE TO USER appadmin
    DB20000I  The SQL command completed successfully.
    Or, provide full database administrator privileges to the new created user:
    db2 => GRANT DBADM ON DATABASE TO USER appadmin
    DB20000I  The SQL command completed successfully.
  6. If you plan to use temporary table emulation, you must setup the database for DB2 global temporary tables (create a user temporary tablespace and grant privileges to all users).
  7. Connect as the application administrator:
    Open a new database connection:
    db2 => connect to dbname user appadmin using password
    
       Database Connection Information
    
     Database server        = DB2/LINUX 10.1.0
     SQL authorization ID   = DB2INST
     Local database alias   = dbname
  8. Create the application tables with CREATE TABLE statements.
    Convert Informix® data types to DB2 data types. See issue Data Type Conversion Table for more details.
  9. If you plan to use SERIAL column emulation, you must prepare the database.