SQL Reference

CREATE NICKNAME

The CREATE NICKNAME statement creates a nickname for a data source table or view.

Invocation

This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared. However, if the bind option DYNAMICRULES BIND applies, the statement cannot be dynamically prepared (SQLSTATE 42509).

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following:

In addition, the user's authorization ID at the data source must hold the privilege to select from the data source catalog the metadata about the table or view for which the nickname is being created.

Syntax

>>-CREATE NICKNAME------nickname-----FOR--remote-object-name---><
 

Description

nickname
Names the federated server's identifier for the table or view that is referenced by remote-object-name. The nickname, including the implicit or explicit qualifier, must not identify a table, view, alias, or nickname described in the catalog. The schema name must not begin with SYS (SQLSTATE 42939).

remote-object-name
Names a three-part identifier with this format:

data-source-name.remote-schema-name.remote-table-name

where:

data-source-name
Names the data source that contains the table or view for which the nickname is being created. The data-source-name is the same name that was assigned to the data source in the CREATE SERVER statement.

remote-schema-name
Names the schema to which the table or view belongs.

remote-table-name
Names either of the following identifiers:
  • The name or an alias of a DB2 family table or view
  • The name of an Oracle table or view
  • The table-name cannot be a declared temporary table (SQLSTATE 42995)

Notes

Examples

Example 1: Create a nickname for a view, DEPARTMENT, that is in a schema called HEDGES. This view is stored in a DB2 Universal Database for OS/390 data source called OS390A.

   CREATE NICKNAME DEPT FOR OS390A.HEDGES.DEPARTMENT

Example 2:  Select all records from the view for which a nickname was created in Example 1. The view must be referenced by its nickname. (It can be referenced it by its own name only in pass-through sessions.)
SELECT * FROM OS390A.HEDGES.DEPARTMENT Invalid
SELECT * FROM DEPT Valid after nickname DEPT is created


[ Top of Page | Previous Page | Next Page ]