Was this helpful?
CREATE SYNONYM
Valid in: SQL, ESQL, DBProc, OpenAPI, ODBC, JDBC, .NET
The CREATE SYNONYM statement defines a synonym for a table, view, or index. A synonym is an alias (alternate name) for an object.
The CREATE SYNONYM statement has the following format:
[EXEC SQL] CREATE SYNONYM synonym_name
              FOR [schema.]object
synonym_name
Specifies a valid object name and must not conflict with the names of other tables, views, indexes, or synonyms owned by the user issuing the statement. Synonyms can be used any place that table, view, or index identifiers are required.
References to synonyms in applications are resolved to their base objects at runtime. References to synonyms in definitions of database procedures, views, and permissions are resolved at the time the procedure, view, or permission is defined. For this reason, the synonym must be valid at definition time and at runtime, but can be dropped and recreated in between.
Use the HELP statement to display existing synonyms.
To display all the synonyms that you own
HELP SYNONYM *.
To display all the synonyms that you own and have access to
HELP SYNONYM *.*
Embedded Usage
You cannot use host language variables in an embedded CREATE SYNONYM statement.
Permissions
This statement is available to all users.
Locking
The CREATE SYNONYM statement locks the iisynonym system catalog, and takes an exclusive lock on the table, view, or index for which a synonym is being created.
Related Statements
DROP SYNONYM
HELP SYNONYM
Last modified date: 11/28/2023