Anda di halaman 1dari 20

1. Change current directory to \DB2v9 under the cdrom. 2. Execute setup.exe. The following screen launches.

3. Click Install a Product on the left panel. The following screen apprears.

4. Click the button Install New. The DB2 database software installation screen launches:

5. Click Next:

6. Click the radio box I accept the terms in the license agreement, and then click the button Next. The following screen appears:

7. Keep the pre-selected installation type Typical. Press Next to continue. The following screen appears:

8. Keep the pre-selected option Install IBM DB2 Express Edition on this computer and save my settings in a response file. Click Next to reach the following screen:

9. Keep the default installation folder. Click Next to continue. The next screen launches:

10. Use the default DB2 copy name. NB: It is possible to install multiple copies of DB2 software on the same server. Press Next to move to the next screen.

11. A DB2 instance will be created during the installation process. Please Next to continue. The following screen appears:

12. Select the radio box LocalSystem account. The DB2 instance created during the installation process will be started when the machine boots up. It will be owned by the OS local system account. Please Next to continue:

13. Press Finish to start the installation process. After the installation process finishes, the following screen appears:

14. Under DB2 database software design, a machine can accommodate multiple instances, and an instance can accommodate multiple databases. The DB2 First Steps screen allows the creation of a database under the default instance installed during the installation process. Press the Create the SAMPLE database line to create a sample database. The following screen then appears:

15. Press the Create SAMPLE Database button to create a sample database. The following configuration screen then appears:

16. Choose the default option to create only SQL related objects in the sample database. Please OK to start database creation:

17. After a while, the database will be created and the following screen appears:

Please OK to close the window.

18. To play with the data in the sample database, we need to open a DB2 command window to issue DB2 command. In the Windows start manual, choose Run and run the command db2cmd:

Click OK to launch the following window:

19. Run the command db2 list db directory to list the available database in the default DB2 instance:

There is only one database available. Its name is SAMPLE. 20. To connect to this database, run the command db2 connect to sample:

21. To list the available table in the SAMPLE database, run the command db2 list tables:

22. To list the content of the table DEPT, run the command db2 select * from dept Please note that a pair of double quotes need to be embedded the SQL statement. Otherwise, the asterisk * will be interpreted by OS.

23. To update the department name of department number A00, run the command db2 update dept set deptname = Hello where deptno = A00

24. Rerun the select command to confirm the update was done properly:

25. To terminate the current DB2 session, run the command db2 terminate:

26. It is possible to execute DB2 command in a graphical interface as well using the command db2ce:

The following program launches:

27. To run the connect command, type the command connect to sample; in the upper sub-window and then press the run button (i.e., ). Note: there is a semi-colon at the end of the command. This is the command separator:

It is possible to trigger the command by pressing Control-Enter. The lower subwindow shows the execution result.

28. Press Control-R to clear the result in the lower sub-window:

29. Append a command select * from dept; in the upper sub-window, and then press Control-Enter to run it:

Please note that both the connect command and the select command were run. The first connect command was not necessary since it was run twice.

30. To run the select command only, use the mouse to highlight the select command only, then press Control-Enter to run the highlighted command:

If only the select command is executed, the result will be displayed in the Query Results panel:

31. To display the access plan of the select statement, select the command panel again, highlight the select statement, and then press the access plan button:

The access plan will then be displayed in the access plan panel:

32. The access plan is shown as a tree structure. It is possible to review detailed information of each item by double-clicking on the box. For example, if we double-click on the lowest box named CCHUI.DEPARTMENT, the following screen appears:

It can be seen that the estimated number of records in this table is 14 (the CARD value), and the number of column in the table is 5, and etc.

Anda mungkin juga menyukai