Home > Articles > Data > DB2

  • Print
  • + Share This
This chapter is from the book

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.

  1. First, you want to know how many instances you have in your computer, so you enter:

  2. 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.

  3. 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:

                set DB2INSTANCE=myinst
  4. You again issue db2 get instance to check that myinst is now the current instance.

  5. 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.

  6. 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.

  7. 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 ).

  8. Next, you want to review the contents of the database configuration file (db cfg) for the MYDB2 database:

                db2 get db cfg for mydb2
  9. To review the contents of the Database Manager Configuration file (dbm cfg) you issue:

                db2 get dbm cfg
  10. 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
  11. 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)

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.

  • + Share This
  • 🔖 Save To Your Account