Testing your Db2 Community Edition Docker image installation on Linux systems
Once you have finished installing and configuring your Db2® Community Edition Docker image on your Linux 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.
Enter the following commands to create a sample database and begin executing SQL commands:
db2sampl -force -sql iThis command may cause the following error:If this error occurs, enter the following commands:
Creating database "SAMPLE"... Connecting to database "SAMPLE"... Creating tables and data in schema "DB2INST1"... --ERROR------------------ SQLSTATE = 38503 Native Error Code = -1131 [IBM][CLI Driver][DB2/LINUXX8664] SQL1131N A stored procedure process has been terminated abnormally. Routine name: "SYSPROC.CREATE_SQL_SAMPLE". Specific name: "CREATE_SQL_SAMPLE". SQLSTATE=38503 ------------------------- --ERROR------------------ SQLSTATE = 08007 Native Error Code = -1224 [IBM][CLI Driver] SQL1224N The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated the specified request because of an error or a forced interrupt. SQLSTATE=55032 ------------------------- 'db2sampl' processing complete.
The output should now read
db2 deactivate db sample db2 drop db sample db2 connect to sample
SQL1013N The database alias name or database name "SAMPLE" could not be found. SQLSTATE=42705" 4
db2sampl -force -sql ito generate the sample database.
db2 connect to sample.Once you are connected to the sample database, you can begin executing SQL statements, such as:
to selects all the rows (* means all rows) from the table "department", or
db2 "select * from department"
to select the first row from the table "department". To change the number of rows retrieved, simply increase the number in the command.
db2 "select * from department fetch first 1 rows only"
- If the database returns the expected results, you can enter
db2 connect reset 9to terminate the Db2 database connection.
logoutto end your Docker session.