Once you have finished installing and configuring your Db2® Community Edition
Docker image on your macOS machine, you can test it against the Db2 SAMPLE
database.
About this task
You will create the Db2 SAMPLE database
from the command line, after which you can run simple SQL commands against it to verify that your
Db2
Community Edition instance is working inside the Docker container.
Procedure
-
Enter the following commands to create a sample database and begin executing SQL commands:
- Run
db2 connect to sample
.
Once you are
connected to the sample database, you can begin executing SQL statements, such as:
db2 "select * from department"
to selects all the rows (* means all rows)
from the table "department", or
db2 "select * from department fetch first 1 rows only"
to select the first
row from the table "department". To change the number of rows retrieved, simply increase the number
in the command.
- If the database returns the expected results, you can enter
db2 connect reset
9
to terminate the Db2 database
connection.
- Enter
logout
to end your Docker session.