DB2 Enablement Workshop: Lab 1 - Working With Instances and Databases
DB2 Enablement Workshop: Lab 1 - Working With Instances and Databases
This lab will help you solidify concepts of instances and databases. It is to be completed
following the presentation “DB2 Instances and Databases”.
Prerequisites:
• DB2 Version 8.1.2 Server has been installed (DB2 Express preferred)
Windows Linux
Log into the operating system as user db2admin Login to the OS as user db2inst1
Start Menu > Programs > IBM DB2 > Open a command line shell
Command Line Tools > Command Window
2. View the database manager (instance) configuration file from the operating
system prompt:
EWLab1_Instances_Databases.doc Page 1 of 1
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
Windows Linux
Key Lesson: You can execute operating system commands within the CLP by
prefixing the command with an exclamation mark.
Tip: On windows, you can also use the up and down arrow keys.
EWLab1_Instances_Databases.doc Page 2 of 2
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
2. Verify that a database now exists. Enter the CLP interactive mode again and
show the contents of the database directory:
3. DB2 does not have database users. Instead, DB2 uses userIDs and passwords
defined at the operating system (or network authentication facilities) to
authenticate users. Connect to the SAMPLE database using the userID that you
have currently used to log into the operating system.
Key Lesson: When you do not supply a user id and password, DB2 will try to
authenticate you using your current userID and password.
4. See all connections that currently exist for the current instance
EWLab1_Instances_Databases.doc Page 3 of 3
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
Note: db2bp stands for DB2 background process. CLP connections always appear as
db2bp (UNIX) or db2bp.exe (windows)
Windows:
db2 => connect to sample user db2admin using ibmdb2
Linux:
db2 => connect to sample user db2inst1 using ibmdb2
Key Lesson: to connect using a specific user id, the syntax is:
connect to <dbname> user <userid> using <password>
9. From the output of list tables, you should see that a table called EMPLOYEE
exists. Find out the structure of EMPLOYEE
EWLab1_Instances_Databases.doc Page 4 of 4
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
1. Attempt to stop the instance. You should get an error because your database
connection still exists.
Read the help message carefully. The User Response: message is quite helpful.
Key Lesson: You can find more information about any error or warning by using a
question mark (?) to prefix an SQLCODE
2. To stop the instance, we have to kick off the current connections. In this step,
forcibly disconnect all applications.
_______________________________________________________________
4. Start the db2 instance again so that we can continue working with the db2
instance
EWLab1_Instances_Databases.doc Page 5 of 5
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
To encourage self exploration of the tools, only the task to be performed is asked with
limited step-by-step guidance.
1. Launch the DB2 Control Center and locate the SAMPLE database created in Part 2
above. Be sure to explore the objects in the database.
2. View all connections. If any exist, force them off the instance.
Hint: Database connectivity is provided by the instance
Hint: While lots of options are available, the only thing you really need to
provide is the name of the new database to be created.
4. In the configuration advisor, read the wizard dialogs carefully to understand what is
happening.
Answer the questions as follows, clicking NEXT to proceed to the next step:
• Step 1: (No action required)
• Step 2: 10%
• Step 3: Mixed
• Step 4: Fewer than 10 (short transactions), 5 transactions per minute
• Step 5: Optimize for BOTH
• Step 6: No, database is not populated with data
EWLab1_Instances_Databases.doc Page 6 of 6
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
____________________________________________________________
Key Lesson: DB2 databases, after initial creation, are not well tuned. Therefore, a
good starting point for performance tuning is to run the configuration advisor. As you
continue to work with the database, you may find that some values still need to be
increased. Change parameters only as needed (tuning by exception).
• Increase the DB2 diagnostics level (DIAGLEVEL) from 3 (all errors and
warnings) to 4 (all errors, warnings, and informational messages). Be sure to
check “Update when available”.
o Double click the value (it should be the default value 3)
o Click the lookup box (i.e. [. . .])
o Five value choices are displayed, there are radio buttons with descriptions
corresponding top-to-bottom with the values 0 for “No diagnostic data
captured” through 4 “All errors, warnings, and informational messages”.
6. Stop the DB2 instance, and be sure to select “Disconnect all applications”.
8. View the database configuration file (DB CFG) for database MYDB2
9. Do NOT drop the MYDB2 database. It will be used in the next lab.
EWLab1_Instances_Databases.doc Page 7 of 7
DB2 Enablement Workshop
Lab 1 – Working with Instances and Databases
LAB 1 - Solutions
Part 2:
2.
Database alias SAMPLE
Directory entry type Indirect
4.
Application name: db2bp.exe
Application handle: 2 (your answer may vary)
Database name: SAMPLE
9.
What is the maximum length of JOB column? 8 characters
What is the data type for the Salary Column? DECIMAL(9,2)
Part 3:
1.
What is the SQLCODE associated with the error message? SQL1025N
3.
What error do you get this time, and how does it differ? SQL1024N
This time, we get a different error: database connection does not exist.
Part 4:
4.
In step 10, how do you tell which parameters have new recommended values?
New recommended values are highlighted with bold font.
5.
Was this parameter (DIAGLEVEL) dynamically changeable?
Yes. The parameter was dynamic because the instance did not require re-start
for it to take effect. However, if Update When Available is not selected, the
parameter change will be dynamically changed.
EWLab1_Instances_Databases.doc Page 8 of 8