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, that is, it must be unique within a database and cannot be the same as the name of a global object such as a database, user, or group.
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.
CREATE SYNONYM <synonym> FOR <name>
| 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 | Description |
|---|---|
| CREATE SYNONYM | The command was successful. |
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.
CREATE SYNONYM pr FOR payroll;