Creating a table nickname

If you want to use federated databases, create a tabKe nickname. A nickname is an identifier by which the federated system refers to a data source table or view. Nicknames are generally used to make tables on a remote server appear to be local.

To create a table nickname:

  1. Create a database by issuing the following command from the DB2 Command Line Processor:

    db2 create database databasename

  2. To connect to this database, type

    db2 connect to databasename

  3. To add a local node in the catalog that is a TCP/IP connection to a local server, type

    db2 catalog tcpip node local remote localhost server db2cdb2

  4. Ensure that the Federated parameter is set to ON:

    1. Expand the catalog for your computer in the DB2 Control Center.

    2. Expand the Instances folder.

    3. Right-click on the DB2 UDB instance and click Configure Parameters.

    4. Scroll down to the Environment section and locate the Federated parameter.

    5. If this parameter is OFF, set it to ON, close the Control Center, restart your computer, and then connect to the database.

  5. To create a wrapper, , enter

    db2 create wrapper wrappername
    A wrapper with the default name of drda is used for all DB2 UDB product family data sources.

  6. To create a server sample for DB2 Universal Database Version 8.1, enter

    db2 create server sample type db2/udb version 8.1 wrapper wrappername authorization userid password password options (node 'local', dbname 'databasename')
    , where userid is your DB2 UDB user ID and password is the password for this DB2 UDB user ID.

  7. To create a nickname called tablesnickname, enter

    db2 create nickname tablesnickname for sample.syscat.tables
    Tablesnickname is displayed in the Data Definition view under the Aliases folder.

To test the nickname, type the following command from the Command Line Processor:

db2 select tabname from tablesnickname where tabname like '%TAB%'

 

Parent topic

Defining a database

 

Related concepts

Federated systems