CREATE SYNONYM Statement (create_synonym_statement)

The CREATE SYNONYM statement (create_synonym_statement) defines a synonym (alternative name) for a table name.

Syntax

<create_synonym_statement> ::=
  CREATE [PUBLIC] SYNONYM [<
schema_name>.]<synonym_name> FOR <table_name>

Explanation

The table name (table_name) must not denote a temporary base table. The user must have a privilege for the specified table.

Only the name of the current user is permitted as the schema name (schema_name) in front of the synonym name.

The synonym name can be specified anywhere instead of the table name. This has the same effect as specifying the table name for which the synonym was defined.

PUBLIC

If PUBLIC is specified, the synonym name must not be identical to the name of a synonym defined in PUBLIC. A synonym is generated that can be accessed by all users.

If PUBLIC is not specified, a private synonym is generated that is only known by the current user. In this case, the synonym name must not be identical to the name of an existing base table, view table, or a private synonym of the current user. If a synonym with the same name and the PUBLIC attribute exists, it cannot be accessed by the current user until the private synonym has been dropped.