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:
- Install the IBM® DB2® LUW on your database server.
- 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:For example:
Consider creating your database with the correct database locale (codeset and territory)
$ db2 ... db2 => CREATE DATABASE dbname AUTOMATIC STORAGE YES USING CODESET UTF-8 TERRITORY EN_US DB20000I The CREATE DATABASE command completed successfully.
-
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/LINUXX8664 11.5.0.0 SQL authorization ID = DB2USER Local database alias = dbname
- 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.
- 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.
- 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).See Temporary tables.
- Connect as the application administrator:Open a new database connection:
db2 => connect to dbname user appadmin using password Database Connection Information Database server = DB2/LINUXX8664 11.5.0.0 SQL authorization ID = DB2USER Local database alias = dbname
- 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. - If you plan to use SERIAL column emulation, you must prepare the database.