SQL$HELP_OLD72.HLB  —  CREATE  SYNONYM
    Creates an alternate name or synonym for an existing database
    object. The object may be a domain, function, module, procedure,
    sequence, another synonym, table, or view.

    Once defined, the synonym can be used in any query or data
    definition language statement in place of the referenced object.

    However, the SHOW commands do not accept synonyms. Use the SHOW
    SYNONYM statement to determine if the name is a synonym.

1  –  Environment

    You can use the CREATE SYNONYM statement:

    o  In interactive SQL

    o  Embedded in host language programs

    o  As part of a procedure in an SQL module or other compound
       statement

    o  In dynamic SQL as a statement to be dynamically executed

2  –  Format

  CREATE -+---------------+-+-----------+---+
          +-> OR REPLACE -+ +-> PUBLIC -+   |
   +------------------ <--------------------+
   +-> SYNONYM <synonym-name> FOR -+----------------+-+
                                   +-> object-type -+ |
   +---------------------- <--------------------------+
   +-> <object-name> -+-----------------------------------------+->
                      +-> COMMENT IS -+-> ' <quoted-string> ' -++
                                      +--------- / <-----------+

  object-type =

  -+-> DOMAIN ----+->
   +-> FUNCTION --+
   +-> MODULE ----+
   +-> PROCEDURE -+
   +-> SEQUENCE --+
   +-> SYNONYM ---+
   +-> TABLE -----+
   +-> VIEW ------+

3  –  Arguments

3.1  –  COMMENT IS 'quoted-string'

    This optional clause can be used to add several lines of comment
    to the synonym object. The comment is displayed by the SHOW
    SYNONYM statement.

3.2  –  FOR object-name

    The name of the database object for which the synonym is
    required. This name must exist for an object in the database. If
    the optional object type is omitted, then Oracle Rdb will search
    the database for an object with this name.

3.3  –  object-type

    Syntax options:

       DOMAIN
       FUNCTION
       MODULE
       PROCEDURE
       SEQUENCE
       SYNONYM
       TABLE
       VIEW

    These optional object types can be used when the referenced
    object name is not unique within the database. For instance,
    Oracle Rdb allows a domain and a table to both be called MONEY.
    Therefore, to create a synonym for the table MONEY, you must use
    the FOR TABLE clause so that it is uniquely identified.

3.4  –  OR_REPLACE

    Instructs SQL to replace any synonym of this name if it exists.
    If it does not exist, a new synonym is created. This shorthand
    allows replacement of an existing synonym while maintaining
    all the dependencies established by query and DDL usage of this
    synonym.

3.5  –  PUBLIC

    This optional clause is provided for compatibility with the
    Oracle database server. It is currently not used by Oracle
    Rdb. Its presence or absence may be used by future releases.
    Oracle Corporation recommends you use the PUBLIC keyword in
    applications.

3.6  –  synonym-name

    The name of the synonym you want to create. The synonym name
    must be unique within all domains, tables, views, functions,
    procedures, modules, sequences, and synonyms within the database.
    You may qualify it with an alias.

4  –  Examples

    Example 1: Using the Default Alias

    SQL> CREATE SYNONYM emps FOR employees;

    Example 2: Using an Explicit Alias for the Synonym

    SQL> CREATE SYNONYM db1.emps FOR employees;

    Example 3: Using an Explicit Alias for the Referenced Object

    SQL> CREATE SYNONYM emps FOR db1.employees;

    Example 4: Using the Alias Explicitly

    SQL> CREATE SYNONYM db1.emps FOR db1.employees;

    Example 5: Using the Table Type

    SQL> CREATE SYNONYM cash FOR table money
    cont>   COMMENT IS 'use a different name to avoid confusion with'
    cont>   /          'the domain MONEY';

    Example 6: Using Multiple Synonyms

    SQL> CREATE TABLE t_employees_0001 (...);
    SQL> CREATE SYNONYM employees FOR t_employees_0001;
    SQL> CREATE SYNONYM emps FOR employees;
Close Help