IBM Db2 Practice: Creating a Simple Database
In this practice, we will create a simple database using IBM Db2. We will start by creating a table to store information about employees, and then we will insert data into the table and query the data.
Step 1: Connect to IBM Db2 To connect to an IBM Db2 database, you will need to use a client program, such as the IBM Data Server Manager. To connect to the database, follow these steps:
- Open the IBM Data Server Manager.
- Click on the “Connect” button.
- Enter the host name or IP address of the IBM Db2 database.
- Enter the port number for the IBM Db2 database (the default port is 50000).
- Enter your IBM Db2 username and password.
Step 2: Create a Table Once you are connected to the IBM Db2 database, create a table named employees
to store information about employees. The table should have the following columns:
id
: the employee ID (integer)name
: the employee name (string)age
: the employee age (integer)position
: the employee position (string)
Step 3: Insert Data into the Table Now that you have created the employees
table, insert the following data into the table:
id | name | age | position |
---|---|---|---|
1 | John Doe | 32 | Manager |
2 | Jane Smith | 28 | Junior Developer |
3 | Jim Brown | 40 | Senior Developer |
4 | Sarah Johnson | 35 | Project Manager |
Step 4: Query Data from the Table Finally, query the data from the employees
table to verify that the data was inserted correctly. Your query should return the four rows of data you inserted earlier.
Step 5: Update the Data Now update the position of employee with id=3 from “Senior Developer” to “Team Lead”.
Step 6: Delete Data from the Table Finally, delete the employee with id=2 from the employees
table.
Conclusion In this practice, we created a simple database using IBM Db2 and inserted data into the table. We also queried the data and updated and deleted records. This practice should help you understand the basic operations you can perform with IBM Db2.