Registering nicknames for Db2 tables and views

For each Db2 server definition, register a nickname for each table and view that you want to access. Then use the nicknames, not the names of the data source objects, when you query the Db2 database.

Before you begin

Before you register a nickname, use the Db2 RUNSTATS command to update the statistics at the Db2 data source. The federated server uses the data source statistics to optimize query processing.

About this task

To create a nickname, you specify a unique name and the name of your remote object, for example, a table or view. For Db2 Database you can also specify the alias of a table, view, or nickname. For Db2 for z/OS® or Db2 for IBM® i, you can specify the alias of a table or view.


You cannot create a nickname on a Db2 database alias.


To register a nickname, use one of the following methods:
Method Description
Use the Administration Explorer in IBM Data Studio. In the Federated Database Objects folder, right-click the Nicknames folder, and select Create Nickname.
Issue the CREATE NICKNAME statement.
For example:

FOR server_definition_name."remote_schema"."remote.table" ;

When you create the nickname, the federated server queries the data source catalog by using the nickname. This query tests the connection to the data source table or view. If the connection does not work, you receive an error message.

What to do next

After you complete this task, you can use nicknames to access data source objects and perform many other operations such as creating a nickname over a temporal table.