Creating the SAMPLE database

To create the SAMPLE database on the command line, use the db2sampl command.

Before you begin

  1. You must have System Administrator (SYSADM) or System Control (SYSCTRL) authority to create a database. SYSADM and SYSCTRL are the first and second highest levels of authority for Db2® databases.
  2. Review the db2sampl command syntax, the various command options, and restrictions on the use of the command.

Procedure

To create the database, do the following on the server:

  1. Ensure that the location of db2sampl (the program that creates the SAMPLE database) is in your path.
    The db2profile or db2cshrc scripts put db2sampl in your path, so it remains there unless you change it.
    • On Linux® and UNIX servers, db2sampl is located in:
         $HOME/sqllib/bin
      where $HOME is the home directory of the Db2 instance owner.
    • On Windows, db2sampl is located in:
         %DB2PATH%\bin
      where DB2PATH is where the Db2 copy is installed.
  2. Ensure that the DB2INSTANCE environment variable is set to the name of the instance where you want to create the SAMPLE database. If it is not set, you can set it with the following commands:
    • On Linux and UNIX, 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
    • On Windows, enter:
         set DB2INSTANCE=instance_name
      where instance_name is the name of the database instance.
  3. Create the default SAMPLE database by entering db2sampl at the command line:
       db2sampl options
    Note: There are options available for customizing how and where the SAMPLE database is created. Refer to the db2sampl command syntax for a complete list of these options as well as other options before creating the database.
    As an example of using an option, if you want to specify where the SAMPLE database is created, you can specify the -dbpath parameter and the location. On UNIX operating systems, this location is a path, for example: "$HOME", and would be entered as:
       db2sampl -dbpath path
    For example:
       db2sampl -dbpath $HOME
    On Windows, this location is a drive, for example: "C:", and would be entered as:
       db2sampl -dbpath drive
    For example:
       db2sampl -dbpath C:
    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. The authentication type for the database is the same as the instance in which it is created.