为什么不应该禁用 ONLY_FULL_GROUP_BY [英] Why should not disable ONLY_FULL_GROUP_BY

查看:106
本文介绍了为什么不应该禁用 ONLY_FULL_GROUP_BY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在互联网搜索期间,我现在看到很多关于禁用 ONLY_FULL_GROUP_BY 功能的问题,所以这意味着很多开发人员在这种严格模式下编写 SQL 查询时遇到了麻烦.

During internet searching I see lot of questions now to disable ONLY_FULL_GROUP_BY feature, so it mean lot of developers have a trouble with writing SQL queries in this strict mode.

我知道禁用此限制非常简单,但现在我问:为什么我不应该这样做?

I know it pretty simple to disable this limitation, but now I ask asking: Why shouldn't I do this?

去除ONLY_FULL_GROUP_BY限制会带来什么问题或副作用?

What problems or side effects will be involved by removing ONLY_FULL_GROUP_BY limitation?

推荐答案

如果没有 ONLY_FULL_GROUP_BY 强制执行的严格性,您可以:

Without the strictness that ONLY_FULL_GROUP_BY enforces, you may:

  • 没有意识到您有错误的查询;
  • 获取一些没有特定含义的列;
  • 你得到的结果,可能不是出现在不同的服务器上,或在下一次升级时,或当查询计划更改(添加/删除/更新数据).

所以听ONLY_FULL_GROUP_BY.它强烈警告您的查询不正确.错误只是说您的 GROUP BY 子句与返回的结果集不兼容.其他数据库默认强制执行,结果是它的用户编写了更好的 SQL.

So listen to ONLY_FULL_GROUP_BY. Its a strong warning that your query isn't right. The error is simply saying your GROUP BY clause is incompatible with the set of results being returned. Other databases enforce it by default, and its users write better SQL as a result.

忽略警告就像 Web 开发人员 chmod a+rwx 一样,因为他们无法计算文件权限.花点时间了解您工作的环境,这样您的体验会更好.下一个人(可能是您未来的自己)也会查看 SQL.

Ignoring warnings is like web developers that chmod a+rwx because they can't work out file permissions. Take the time to understand the environment in which you are working and you'll be better off for the experience. And so will the next person, potentially your future self, that looks at the SQL.

这篇关于为什么不应该禁用 ONLY_FULL_GROUP_BY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆