June 19th, 2009

Data Definition Language, CREATE ALIAS or SYNONYM

Posted by admin in Q. Data Definition Language

Format:

          CREATE [PUBLIC | PRIVATE] ALIAS alias_name
             FOR {table_name | view_name};

or

          CREATE [PUBLIC | PRIVATE] SYNONYM synonym_name
             FOR {table_name | view_name};

An alias or synonym produces another name for a table or view.
The normal use of an alias or symonym is to avoid having to qualify another user’s table or view.
An alias or synonym simplifies the SQL statement and make it appear to be your own table.

A PRIVATE alias or synonym can only be accessed by the creator of the alias or synonym.
If unspecified, PRIVATE is the default.

A PUBLIC alias or synonym is accessible to all users of the database.
Normally only a Database Administrator or a privileged security user can create with PUBLIC.

Example:

          CREATE SYNONYM PILOTS FOR USER1.PILOT_TBL;

> Aliases and synonyms are not an SQL standard.

> DB2, Informix, and Oracle implement ALIAS and SYNONYM.

> MySQL does not implement ALIAS or SYNONYM.

Comments are closed.

Sorry, the comment form is closed at this time.