Cataloging a database from a client by using the CLP

This task describes how to catalog a database from a client by using the command line processor (CLP).

Before you begin

Before a client application can access a remote database, the database must be cataloged on the client. When you create a database, the database is automatically cataloged on the server with a database alias that is the same as the database name, unless a different database alias was specified.

The information in the database directory, along with the information in the node directory (unless you are cataloging a local database where a node is not needed), is used on the IBM® data server client to establish a connection to the remote database.

  • You require a valid Db2® user ID. Db2 does not support using root authority to catalog a database.
  • You must have System Administrative (SYSADM) or System Controller (SYSCTRL) authority, or have the catalog_noauth option set to ON.
  • You need the following information when cataloging a remote database:
    • Database name
    • Database alias
    • Node name
    • Authentication type (optional)
    • Comment (optional)
    Refer to the parameter values worksheet for cataloging a database for more information about these parameters and to record the values that you use.
  • The following parameter values are applicable when cataloging a local database:
    • Database name
    • Drive
    • Database alias
    • Authentication type (optional)
    • Comment (optional)
    Local databases can be uncataloged and recataloged at any time.

Procedure

To catalog a database on the client:

  1. Log on to the system with a valid Db2 user ID.
  2. Optional: Update the Your Value column in the Parameter values worksheet for cataloging a database.
  3. If you are using the Db2 database on a Linux® or UNIX platform, set up the instance environment.
    Run the startup script:
    For bash, Bourne or Korn shell
       . INSTHOME/sqllib/db2profile
    For C shell
       source INSTHOME/sqllib/db2cshrc
    where: INSTHOME represents the home directory of the instance.
  4. Start the Db2 command line processor.
    On Windows operating systems, issue the db2cmd command from a command prompt. On Linux or UNIX, issue the db2 command from a command prompt.
  5. Catalog the database by entering the following commands in the command line processor:
    db2 => catalog database database_name as database_alias at
       node node_name [ authentication auth_value ]
    where:
    • database_name represents the name of the database you want to catalog.
    • database_alias represents a local nickname for the database you want to catalog.
    • node_name represents a nickname you can set for the computer that has the database you want to catalog.
    • auth_value specifies the type of authentication that takes place when connecting to the database. This parameter defaults to the authentication type specified on the server. Specifying an authentication type can result in a performance benefit. Examples of valid values include: SERVER, CLIENT, SERVER_ENCRYPT, KERBEROS, GSSPLUGIN and SERVER_ENCRYPT_AES.

Example

To catalog a remote database called SAMPLE so that it has the local database alias MYSAMPLE, on the node DB2NODE using authentication SERVER, enter the following commands:
db2 => catalog database sample as mysample at node db2node
       authentication server
db2 => terminate