Previous Topic Next topic Print topic


CREATE ALIAS

The CREATE ALIAS command defines an alternate name for an existing table or view, and records the alias definition in the XDB Server system catalog at the currently set location. It is not required that the table or view be in the current location.
Restriction: This topic applies to Windows environments only.

Invocation

This statement can be embedded in an application program or issued interactively.

Authorization

To execute the CREATE ALIAS command, you must possess either the CREATEALIAS privilege, or overall SYSADM or SYSCTRL authority for the location. If the alias-name specified includes an authorization name qualifier that does not match the AuthID, the privilege set must include SYSADM or SYSCTRL authority for the location. When the specified alias-name includes an authorization name qualifier that does not match the process AuthID, any authorization name qualifier is valid, if the application process privilege set includes SYSADM or SYSCTRL authority.

Syntax

CREATE ALIAS alias-name
    FOR {table-name | view-name}

Parameters:

alias-name Names the alias, and must not match the name of any table, view, alias, or synonym that already exists at the currently set location.
table-name or view-name Identifies the table or view for which the alias is defined. If a table is identified, it must not be an auxiliary table or a declared temporary table. The table or view need not exist at the time the alias is defined. If it does exist, it can be at the current server or at another server. The name must not be the same as the alias name and must not identify an alias that exists at the current server.

Description

The alias name can be either a one-part, two-part or three-part qualified name (location-name.AuthID.alias-name). The AuthID qualifier within alias-name identifies the alias owner. If the CREATE ALIAS statement is dynamically prepared and the alias name is unqualified, the application process AuthID becomes the alias owner.

The table or view need not exist when the CREATE ALIAS statement is executed. Already defined tables or views can exist at either the currently set location or a different location. The table or view name must not match the alias name, and must not match any other alias names described in the catalog at the current XDB Server location.

An alias can be defined for a table, view or other alias whose name does not exist under the current XDB Server location. In this case, the existence of the referenced object is not verified by the XDB Server when the alias is created. The XDB Server can detect an alias specified for a location other than the current location. In these cases, the full three-part name that the alias references is substituted in the query for the alias name. The new query is then sent to the location specified in the three-part name.

Example:

The following example creates an alias called bob, and then uses that alias in a query:

CREATE ALIAS bob FOR tutorial.tutorial.customer

When the query shown below references bob, the three-part name value defined above is substituted, and the query sent to the TUTORIAL location.

SELECT * FROM bob
Previous Topic Next topic Print topic