A synonym in databases is an alternative name or alias for a table, view, sequence, or other schema items. They are mostly used to simplify access for users to database objects owned by other users.
Its purpose is to offer a different name for the base object, a different database item that may be present on a local or remote server.
To insulate a client application from alterations made to the base object’s name or location, an abstraction layer is provided.
Note that four-part names for function base objects are not supported.
Examples:
USE TestDatabase;
GO
CREATE SYNONYM Trxns
FOR TestDatabase.Trxns.tbTransactions;
GO
Without using the database name or the schema name, the data can be inserted into the base table, as shown below:
INSERT INTO Trxns (…..) VALUES (……);
One comment