是否有已发布的 SQL 编码风格指南?
通常我会得到非常复杂的 SQL 语句,我想知道是否有样式指南规定了布置查询各个方面的通用方法。
我正在寻找类似于 Python's PEP8 或 Zend Frameworks 指南,而不是示例代码。
我的大部分查询都是为 MySQL 编写的。
那么您知道通用风格指南吗?也许你自己写过一篇。请分享您的指导方针。
Often I will end up with very complex SQL statements and I wondered if there was style guideline out there that dictates a common way of laying various aspects of a query out.
I am look for something descriptive along the lines of Python's PEP8 or Zend Frameworks guidelines and not code by example.
Most of my queries are written for MySQL.
So do you know of a universal style guide? Perhaps you have written one yourself. Please share your guidelines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
自从提出这个问题以来,我根据知识共享署名-相同方式共享许可编写了一份公共 SQL 风格指南,该指南与 Joe Celko 的 SQL 编程风格书兼容。
它可以在 www.sqlstyle.guide 或 直接从 GitHub 存储库降价。
Since asking this question I have written a public SQL style guide that is compatible with Joe Celko's SQL Programming Style book under the Creative Commons Attribution-ShareAlike licence.
It is available over at www.sqlstyle.guide or as markdown directly from the GitHub repo.
以下是我们收集的一些 SQL 编程指南和最佳实践:
)可以在 这篇博文。
Here are some SQL programming guidelines and best practices we collected:
You can check detailed explanation of those best practices in this blog post.
我知道的两个指南是 Joe Celko 的 SQL 编程风格 和可敬的 代码完成。
还有 SQL-92 标准。它不包含样式部分,但您可能认为它的样式是隐式规范的。
Two guides I know of are Joe Celko's SQL Programming Style and the venerable Code Complete.
There's also the SQL-92 standard. It doesn't contain a style section, but you might consider it's style to be implicitly canonical.
MySQL对其或多或少严格的规则有一个简短的描述:
https:// /dev.mysql.com/doc/internals/en/coding-style.html
Simon Holywell 的 MySQL 最常见编码风格:
http://www.sqlstyle.guide/
另请参阅这个问题:
MySQL 有命名约定吗?
MySQL has a short description of their more or less strict rules:
https://dev.mysql.com/doc/internals/en/coding-style.html
Most common codingstyle for MySQL by Simon Holywell:
http://www.sqlstyle.guide/
See also this question:
Is there a naming convention for MySQL?
Kickstarter 这里有一个风格指南。我为那些喜欢小写 SQL 和 Celko 的“河流”。
我的风格指南在这里。这是一个示例:
Kickstarter has a style guide here. I have a modified version of that for people who prefer lowercase SQL and Celko's "river".
My style guide is here. Here is a sample:
您是否考虑过让您的团队使用具有内置格式化功能的工具?Toad for MySql 有这个。它本身不会成为指南,但至少会带来一定的一致性。
Have you thought about getting your team to use a tool with built in formatting capabilities?Toad for MySql has this. Its not going be a guide as such but a least will bring some consistency.