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:
- Create a database by issuing the following command from the DB2 Command Line Processor:
db2 create database databasename- To connect to this database, type
db2 connect to databasename- 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- Ensure that the Federated parameter is set to ON:
- Expand the catalog for your computer in the DB2 Control Center.
- Expand the Instances folder.
- Right-click on the DB2 UDB instance and click Configure Parameters.
- Scroll down to the Environment section and locate the Federated parameter.
- If this parameter is OFF, set it to ON, close the Control Center, restart your computer, and then connect to the database.
- To create a wrapper, , enter
db2 create wrapper wrappernameA wrapper with the default name of drda is used for all DB2 UDB product family data sources.- 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.- To create a nickname called tablesnickname, enter
db2 create nickname tablesnickname for sample.syscat.tablesTablesnickname 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