Why should not disable ONLY_FULL_GROUP_BY

安稳与你 提交于 2020-12-13 05:56:57

问题


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?

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


回答1:


Without the strictness that ONLY_FULL_GROUP_BY enforces, you may:

  • not realize you have the wrong query;
  • be getting some columns that don't have a specific meaning;
  • the results that you are getting, may not be the results that appear on a different server, or on the the next upgrade, or when the query plan changes (added/deleted/updated data).

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.

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.



来源:https://stackoverflow.com/questions/64824498/why-should-not-disable-only-full-group-by

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