To use the sample programs shipped with DB2, you need to create the sample database on a server workstation. Refer to the SQL Reference for a listing of the contents of the sample database.
If you will be using a remote client to access the sample database on the server, you need to catalog the sample database on the client workstation.
Also, if you will be using a remote client to access the sample database on a server that is running a different version of DB2, or running on a different operating system, you need to bind the database utilities, including the DB2 CLI, to the sample database.
To create the sample database, you must have SYSADM authority. If you need more information about SYSADM authority, refer to the Quick Beginnings book for your operating system.
To create the database, do the following on the server:
$HOME/sqllib/bin
where $HOME is the home directory of the DB2 instance owner.
%DB2PATH%\bin
where %DB2PATH% is where DB2 is installed.
you can do this for the bash or Korn shell by entering:
DB2INSTANCE=instance_name export DB2INSTANCE
and for the C shell by entering:
setenv DB2INSTANCE instance_name
set DB2INSTANCE=instance_name
where instance_name is the name of the database instance.
db2sampl path
On OS/2 and Windows, this is a drive, and would be entered as:
db2sampl drive
If you do not specify the path or drive, the installation program installs the sample tables in the default path or drive specified by the DFTDBPATH parameter in the database manager configuration file. If you need information about the configuration file, refer to the Administration Guide.
The authentication type for the database is the same as the instance in which it is created. If you need more information about specifying authentication when creating a database instance, refer to the Quick Beginnings book.
Creating on Host or AS/400 Servers
If you want to run the sample programs against a Host server such as DB2 for OS/390, or an AS/400 server, you need to create a database that contains the sample tables described in the SQL Reference. You may want to refer to the sample program, expsamp (C: expsamp.sqc ; COBOL: expsamp.sqb ), which uses the STAFF and ORG tables to demonstrate how APIs are used to import and export tables and table data to and from a DB2 Connect database.
To create the database:
If you need information about exporting and importing files, refer to the Data Movement Utilities Guide and Reference. If you need information about connecting to a database and creating tables, refer to the SQL Reference.
To access the sample database on the server from a remote client, you need to catalog the sample database on the client workstation.
You do not need to catalog the sample database on the server workstation because it was cataloged when you created it.
Cataloging updates the database directory on the client workstation with the name of the database that the client application wants to access. When processing client requests, the database manager uses the cataloged name to find and connect to the database.
The Quick Beginnings book provides general information on cataloging databases. This section provides specific instructions on cataloging the sample database.
To catalog the sample database from the remote client workstation, enter:
db2 catalog database sample as sample at node nodename
where nodename is the name of the server node.
The Quick Beginnings book explains how to catalog nodes as part of setting up communication protocols. You must also catalog the remote node before you can connect to the database.