CREATE SYNONYM

Use the CREATE SYNONYM statement to create a synonym for a table name or view name.

The name of a synonym is subject to the same restrictions as the name of a table or view. The synonym name must be unique within each schema of a database.

You can create a synonym for a nonexistent table or view. At run time, the system expands the object name to its fully qualified form. If the referenced object does not exist, the system displays an error message.

Syntax

Syntax for creating a synonym:
CREATE SYNONYM <synonym> FOR <name>

Inputs

The CREATE SYNONYM command takes the following inputs:
Table 1. CREATE SYNONYM inputs
Input Description
<synonym> The name of the synonym.
<name> The name of the table or view for which the synonym is to be created.

Output

The CREATE SYNONYM command produces the following output:
Table 2. CREATE SYNONYM output
Output Description
CREATE SYNONYM The command was successful.

Privileges

You must be the admin user, the owner of the database or schema where the synonym is defined, or your account must have the Create Synonym privilege.

Usage

The following provides sample usage:
  • To create a synonym pr for the table payroll:
       CREATE SYNONYM pr FOR payroll;