SQL Server - Synonyms Tips & Tricks? [closed]

穿精又带淫゛_ 提交于 2019-12-03 06:08:00

As a synonym is an abstraction/alternative name for an already existing database object, in the case of a table, index behaviour is identical to that of the underlying object i.e. when execution plans are generated, the same plan is generated irrespective of using the table name or corresponsing synonym.

Jarred Froman

Actually, I have come across a gotcha when using indexes.... I'm not sure if there is a way to create related posts on this site, but here is the link to my issue with synonyms and table indexes.

SQL Server Table Synonyms with Indexes

Yes, synonyms can be used as an abstraction layer, or layer of indirection. For instance, if you need to access objects in an external database where the actual database name will not be known until runtime. You can write your sql referring to objects by synonym name, and then dynamically create the synonyms later.

There are no index gotchas: if the synonym refers to a table or indexed view, then whatever indexes are defined on those objects are in play.

Performance should be the same as explicitly referring to the object by fully-qualified name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!