2.5 Case Study: The DB2 Environment
You recently attended a DB2 training class and would like to try things out on your own laptop at the office. Your laptop is running Windows 2000 and DB2 UDB Enterprise Server Edition has been installed. You open the Command Window and take the following steps.
First, you want to know how many instances you have in your computer, so you enter:
Then, to find out which of these instances is the current active one, you enter:
db2 get instance
With the db2ilist command, you found out there were two instances defined on this computer, DB2 and myinst. With the db2 get instance command, you learned that the DB2 instance is the current active instance.
You would now like to list the databases in the myinst instance. Since this one is not the current active instance, you first switch to this instance temporarily in the current Command Window:
You again issue db2 get instance to check that myinst is now the current instance.
To list the databases defined on this instance you issue:
db2 list db directory
This command shows that you only have one database (MYDB2) in this instance.
You want to try creating a new database called TEMPORAL, so you execute:
db2 create database temporal
The creation of the database takes some time because several objects are created by default inside the database. Issuing another list db directory command now shows two databases: MYDB2 and TEMPORAL.
You connect to the MYDB2 database ( db2 connect to mydb2 ) and check which tables you have in this database ( db2 list tables for all ). You also check how many table spaces are defined ( db2 list tablespaces ).
Next, you want to review the contents of the database configuration file (db cfg) for the MYDB2 database:
db2 get db cfg for mydb2
To review the contents of the Database Manager Configuration file (dbm cfg) you issue:
db2 get dbm cfg
At this point, you want to practice changing the value of a dbm cfg parameter, so you pick the INTRA_PARALLEL parameter which has a value set to YES. You change its value to NO as follows:
db2 update dbm cfg using INTRA_PARALLEL NO
You learned at the class that this parameter is not "configurable online," so you know you have to stop and start the instance. Since there is a connection to a database in the current instance (remember you connected to the MYDB2 database earlier from your current Command Window), DB2 will not allow you to stop the instance. Enter the following sequence of commands:
db2 terminate (terminates the connection) db2stop db2start
And that's it! In this case study you have reviewed some basic instance commands like db2ilist and get instance . You have also reviewed how to switch to another instance, create and connect to a database, list the databases in the instance, review the contents of the database configuration file and the database manager configuration file, update a database manager configuration file parameter, and stop and start an instance.