dbo。数据库对象名称中的前缀,我可以忽略它吗?

时间:2022-05-19 07:27:41

I am looking for a performant default policy for dealing with the .dbo prefix.

我正在寻找一个处理.dbo前缀的高性能默认策略。

I realize that the dbo. prefix is more than syntactic noise, however I got through the past 8 years of MS based development skipping typing the dbo. prefix and ignoring its function.

我意识到dbo。前缀不仅仅是语法噪音,但是我通过过去8年的基于MS的开发跳过键入dbo。前缀并忽略其功能。

Apart from a performance issue with stored proc compile locks is there a downside to skipping typing ".dbo" in SQLqueries and stored procedures?

除了存储过程编译锁的性能问题,在SQLqueries和存储过程中跳过键入“.dbo”还有一个缺点吗?

Further background: All my development is web middle-tier based with integrated security based on a middle tier service account.

进一步背景:我的所有开发都是基于中间层服务帐户的集成安全性的Web中间层。

6 个解决方案

#1


12  

[dbo].[xxx]

[DBO]。[XXX]

The SQL Server engine always parse the query into pieces, if you don't use the prefix definitely it going search for object in similar name with different users before it uses [dbo]. I would suggest you follow the prefix mechanism not only to satisfy the best practices, also to avoid performance glitches and make the code scalable.

SQL Server引擎总是将查询解析成碎片,如果你不使用前缀肯定会在使用[dbo]之前搜索具有不同用户的类似名称的对象。我建议你遵循前缀机制不仅要满足最佳实践,还要避免性能故障并使代码可扩展。

I don't know I answered your question, but these are just my knowledge share

我不知道我回答了你的问题,但这些只是我的知识分享

#2


9  

Most of the time you can ignore it. Sometimes you will have to type it. Sometimes when you have to type it you can just type an extra '.':

大多数时候你可以忽略它。有时你必须输入它。有时当你必须输入它时,你只需输入一个额外的'。':

SELECT * FROM [LinkedServer].[Database]..[Table]

You'll need to start watching for it if you start using extra schemas a lot more, where you might have two schemas in the same database that both have tables with the same name.

如果你开始使用额外的模式,你需要开始观察它,你可能在同一个数据库中有两个模式,它们都有相同名称的表。

#3


3  

The main issue is not security, is name conflict resolution, in the case that your application will ever be deployed side-by-side with another application using the same names in the database.

如果您的应用程序将与使用数据库中相同名称的另一个应用程序并排部署,则主要问题不是安全性,而是名称冲突解决方案。

If you package and sale your product, I would strongly advise to use schemas, for the sake of your costumers. If you develop for a one particular shoppe, then is not so much of a concern.

如果您打包和销售您的产品,我强烈建议您使用架构,以满足您的客户需求。如果你为一个特定的专柜开发,那么就不用担心了。

#4


3  

Yes you can ignore - for the most part - if you never ever create anything outside the (default) "dbo" schema. One place you can't ignore it is when calling a stored function - that always has to have the "two-part" notation:

是的,你可以忽略 - 在大多数情况下 - 如果你从未在(默认)“dbo”架构之外创建任何东西。一个你不能忽视它的地方是在调用存储函数时 - 总是必须有“两部分”符号:

select * from dbo.myFunc

However, it is considered a best practise to always use the "dbo." prefix (or other schema prefixes, if your database has several schemas).

但是,始终使用“dbo”被认为是最佳做法。前缀(或其他模式前缀,如果您的数据库有多个模式)。

Marc

渣子

#5


2  

"however I got through the past 8 years of MS based development skipping typing the dbo. prexfix and ignoring its function."

“但是,我通过过去8年的基于MS的开发跳过键入dbo.prexfix并忽略了它的功能。”

This is your answer. If your DB is performing fine you are OK. Best practices don't replace real testing on your actual system. If your performance is fine and maintenance is OK, your time is better spent elsewhere where you can get better bang for your proverbial buck.

这是你的答案。如果你的数据库表现良好你就可以。最佳实践不会取代实际系统上的实际测试。如果你的表现很好并且维护得很好,你的时间最好花在其他地方,这样你可以获得更好的效果。

#6


1  

After working in the oracle world, I would advise against skipping the schema declaration. Remember now that SQL server versions after 7.0 support multiple schemas per database - it is important to distinguish between them to be sure that you are grabbing the proper tables.

在oracle世界工作之后,我建议不要跳过架构声明。现在请记住,7.0之后的SQL Server版本支持每个数据库的多个模式 - 区分它们以确保您正在抓取正确的表非常重要。

If you can ensure that you'll never have two separate schema namespaces per database, then you can ignore it. The dbo. prefix should do nothing to affect performance by itself - parsing is such a small part of the SQL query as to be insignificant.

如果您可以确保每个数据库永远不会有两个单独的模式名称空间,那么您可以忽略它。 dbo。前缀本身不应该影响性能 - 解析是SQL查询的一小部分,无关紧要。

#1


12  

[dbo].[xxx]

[DBO]。[XXX]

The SQL Server engine always parse the query into pieces, if you don't use the prefix definitely it going search for object in similar name with different users before it uses [dbo]. I would suggest you follow the prefix mechanism not only to satisfy the best practices, also to avoid performance glitches and make the code scalable.

SQL Server引擎总是将查询解析成碎片,如果你不使用前缀肯定会在使用[dbo]之前搜索具有不同用户的类似名称的对象。我建议你遵循前缀机制不仅要满足最佳实践,还要避免性能故障并使代码可扩展。

I don't know I answered your question, but these are just my knowledge share

我不知道我回答了你的问题,但这些只是我的知识分享

#2


9  

Most of the time you can ignore it. Sometimes you will have to type it. Sometimes when you have to type it you can just type an extra '.':

大多数时候你可以忽略它。有时你必须输入它。有时当你必须输入它时,你只需输入一个额外的'。':

SELECT * FROM [LinkedServer].[Database]..[Table]

You'll need to start watching for it if you start using extra schemas a lot more, where you might have two schemas in the same database that both have tables with the same name.

如果你开始使用额外的模式,你需要开始观察它,你可能在同一个数据库中有两个模式,它们都有相同名称的表。

#3


3  

The main issue is not security, is name conflict resolution, in the case that your application will ever be deployed side-by-side with another application using the same names in the database.

如果您的应用程序将与使用数据库中相同名称的另一个应用程序并排部署,则主要问题不是安全性,而是名称冲突解决方案。

If you package and sale your product, I would strongly advise to use schemas, for the sake of your costumers. If you develop for a one particular shoppe, then is not so much of a concern.

如果您打包和销售您的产品,我强烈建议您使用架构,以满足您的客户需求。如果你为一个特定的专柜开发,那么就不用担心了。

#4


3  

Yes you can ignore - for the most part - if you never ever create anything outside the (default) "dbo" schema. One place you can't ignore it is when calling a stored function - that always has to have the "two-part" notation:

是的,你可以忽略 - 在大多数情况下 - 如果你从未在(默认)“dbo”架构之外创建任何东西。一个你不能忽视它的地方是在调用存储函数时 - 总是必须有“两部分”符号:

select * from dbo.myFunc

However, it is considered a best practise to always use the "dbo." prefix (or other schema prefixes, if your database has several schemas).

但是,始终使用“dbo”被认为是最佳做法。前缀(或其他模式前缀,如果您的数据库有多个模式)。

Marc

渣子

#5


2  

"however I got through the past 8 years of MS based development skipping typing the dbo. prexfix and ignoring its function."

“但是,我通过过去8年的基于MS的开发跳过键入dbo.prexfix并忽略了它的功能。”

This is your answer. If your DB is performing fine you are OK. Best practices don't replace real testing on your actual system. If your performance is fine and maintenance is OK, your time is better spent elsewhere where you can get better bang for your proverbial buck.

这是你的答案。如果你的数据库表现良好你就可以。最佳实践不会取代实际系统上的实际测试。如果你的表现很好并且维护得很好,你的时间最好花在其他地方,这样你可以获得更好的效果。

#6


1  

After working in the oracle world, I would advise against skipping the schema declaration. Remember now that SQL server versions after 7.0 support multiple schemas per database - it is important to distinguish between them to be sure that you are grabbing the proper tables.

在oracle世界工作之后,我建议不要跳过架构声明。现在请记住,7.0之后的SQL Server版本支持每个数据库的多个模式 - 区分它们以确保您正在抓取正确的表非常重要。

If you can ensure that you'll never have two separate schema namespaces per database, then you can ignore it. The dbo. prefix should do nothing to affect performance by itself - parsing is such a small part of the SQL query as to be insignificant.

如果您可以确保每个数据库永远不会有两个单独的模式名称空间,那么您可以忽略它。 dbo。前缀本身不应该影响性能 - 解析是SQL查询的一小部分,无关紧要。