SQL Server - 同义词提示和 技巧?
我最近进行了大量的数据库重构,同义词变得非常有用。 当我最初放入同义词时,我认为在重构时它们将是非常临时的。 现在我认为保留其中一些同义词可能有一些充分的理由。
有人用它们作为全力一击吗 抽象层?
什么是性能成本?
关于索引有什么陷阱吗?
提示还是技巧?
我的第一个问题,请温柔一点。
谢谢
I've been doing a lot of DB refactoring lately and synonyms have come in incredibly useful. When I originally put in the synonyms I was thinking they would be very temporary while I refactor. Now I am thinking there might be some good reasons to keep some of these synonyms around.
Has anyone used them as full blow
abstraction layer?What are the performance costs?
Any gotchas with indexes?
Tips or Tricks?
My first question, so please be gentle.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于同义词是已存在数据库对象的抽象/替代名称,因此在表的情况下,索引行为与基础对象的行为相同,即生成执行计划时,无论是否使用表,都会生成相同的计划名称或相应的同义词。
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.
实际上,我在使用索引时遇到了一个问题......我不确定是否有办法在该网站上创建相关帖子,但这里是我的同义词和表索引问题的链接。
带有索引的 SQL Server 表同义词
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
是的,同义词可以用作抽象层或间接层。 例如,如果您需要访问外部数据库中的对象,其中实际数据库名称直到运行时才知道。 您可以编写通过同义词名称引用对象的 sql,然后动态创建同义词。
不存在索引陷阱:如果同义词引用表或索引视图,那么在这些对象上定义的任何索引都会起作用。
性能应该与通过完全限定名称显式引用对象相同。
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.