A synonym is an alternate name for a schema scoped object. Synonyms allow client applications to use the single-part name of a synonym to reference a base object instead of a using a two-, three-, or four-part name to reference the base object.
Advantage
It replaces long multi-part object name in SQL Statement
It also provides an abstractions layer which will protect SQL statement using synonyms from changes in underlying objects (tables etc).
Example
-- CREATE SYNONYMS
CREATE SYNONYM MyWork
FOR SQLWorks.dbo.test
-- USE SYNONYMS
SELECT * FROM MyWork
-- DROP SYNONYMS
DROP SYNONYM MyWork
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment