DB2 Version 9.7 for Linux, UNIX, and Windows

Cataloging databases

When you create a new database, it is automatically cataloged in the system database directory file. You might also use the CATALOG DATABASE command to explicitly catalog a database in the system database directory file.

About this task

The CATALOG DATABASE command allows you to catalog a database with a different alias name, or to catalog a database entry that was previously deleted using the UNCATALOG DATABASE command.

Although databases are cataloged automatically when a database is created, you still might have a need to catalog the database. When you do so, the database must exist.

By default directory files, including the database directory, are cached in memory using the Directory Cache Support (dir_cache) configuration parameter. When directory caching is enabled, a change made to a directory (for example, using a CATALOG DATABASE or UNCATALOG DATABASE command) by another application might not become effective until your application is restarted. To refresh the directory cache used by a command line processor session, issue the TERMINATE command.

In a partitioned database, a cache for directory files is created on each database partition.

In addition to the application level cache, a database manager level cache is also used for internal, database manager look-up. To refresh this "shared" cache, issue the db2stop and db2start commands.

To catalog a database with a different alias name using the command line processor, use the CATALOG DATABASE command. For example, the following command line processor command catalogs the PERSON1 database as HUMANRES:
    CATALOG DATABASE personl AS humanres
      WITH "Human Resources Database"

Here, the system database directory entry will have HUMANRES as the database alias, which is different from the database name (PERSON1).

To catalog a database in the system database directory from a client application, call the sqlecadb API.

To catalog a database on an instance other than the default using the command line processor, use the CATALOG DATABASE command. In the following example, connections to database B are to INSTNC_C. The instance instnc_c must already be cataloged as a local node before attempting this command.
    CATALOG DATABASE b as b_on_ic AT NODE instnc_c
Note: The CATALOG DATABASE command is also used on client nodes to catalog databases that reside on database server computers.