E. Working with your database
The database you created in D. Performing initial configuration of your DB2 AMI instances does not contain any data yet. For this tutorial, it might be more useful to work with a database that already contains some data. Follow the steps to understand how to find and use an existing database.
- Open a terminal, and ssh into your instance.
- Enter su - db2inst1 to become the db2inst1 user.
- Enter db2sampl to create the sample database, as shown in Figure 48.
Figure 48. db2sampl command
- Enter db2. The DB2 Command Line Processor (CLP) interface appears, as shown in Figure 49.
Figure 49. DB2 CLP
- Enter connect to SAMPLE to connect to the SAMPLE database, as shown in Figure 50.
Figure 50. Connect to SAMPLE
- Enter list tables to find out which tables are in the SAMPLE database, as shown in Figure 51.
Figure 51. List tables
- Enter other SQL statements to experiment with viewing the data. Figures 52-54 show examples of some statements and results.
Figure 52. Entering the DESCRIBE SELECT * FROM DEPT statement
Figure 53. Entering the SELECT * FROM DEPT statement
Figure 54. Entering the SELECT COUNT(*) FROM DEPT statement
- Enter quit to close the CLP interface, as shown in Figure 55.
Figure 55. Closing the CLP interface
During the initial configuration phase, the Apache Web Server and a PHP application called Technology Explorer for DB2 (TE) were also setup. TE is a useful Web-based tool to monitor DB2 databases and to learn about new features and technologies in DB2. You can access this tool if HTTP port 80 was opened up for your DB2 instance during the security group setup. Optionally follow these steps to use TE.
- Go to
http://<Hostname_of_DB2_Instance>/TEto access TE, as shown in Figure 56.
Figure 56. Access Technology Explorer
- In the top right corner, click New to create a new database connection.
- Enter the details, as shown in Figure 57, and click Connect.
Figure 57. Connecting to a database from the Technology Explorer
- Verify in the top right corner of TE that it is connected to the sample database on your EC2 instance.
- Navigate through the menus of this tool to explore your database and to learn about DB2 features, as shown in Figure 58.
Figure 58. Explore Technology Explorer menus




