DataGrip之一个赏心悦目的SQL格式化模板,快用起来吧
前段时间做需求,同事吐槽我的代码难以阅读,非让我用vs code,从最开始使用的notepad++到sublime,再到datagrip,发现最后一个功能更全一点,所以还是决定坚持用这个工具来格式化我的SQL。如果你懒得去自己一个个试,那么可以套用这个。一、DataGrip的SQL格式化设置菜单1.Preference(command+,)2.Editor->Code Style->G
·
从最开始使用的notepad++到sublime,再到datagrip,发现最后一个功能更全一点,所以还是决定坚持用这个工具来格式化我的SQL。
如果你懒得去自己一个个试,那么可以套用这个。
一、DataGrip的SQL格式化设置菜单
1.Preference(command+,)
2.Editor->Code Style->General
二、格式化模板
1.Queries (查询)
注:未列举的选项均为 As in common/Do not change/不勾选
类别 | 子类 | 选项 | 图例 | 说明 |
Common(常见的) | Align the first word of clause(对齐从句的第一个单词) | To left | 类似于select from、where group by 这种主从句,关键字都是对齐的 | |
Place clause elements on(将子句元素放在) | Same line | |||
Place comma(放置逗号) | To begin | 逗号放前面不容易丢失 | ||
Collapse short statement(折叠简短声明) | Do not change | |||
Align line comments at right of elements(在元素右侧对齐行注释) | ☑️ | |||
INSERT statement and VALUES clause | Place INTO on the new line | no | ||
Put spaces within parentheses(将空格放在括号内) | ☑️ | |||
WITH clause | Align AS | ☑️ | ||
SELECT clause | Wrap elements | chop | ||
Align AS | ☑️ | |||
FROM clause | Wrap the first JOIN | ☑️ | ||
Wrap the next JOIN | ☑️ | |||
Place JOIN in join-only queries under | FROM indented | |||
Align joined tables | ☑️ | |||
Wrap ON/USING | ☑️ | on 另起一行 | ||
Place ON/USING under | Table | on 和表名对齐 | ||
WHERE and HAVING clause | Wrap elements | chop | ||
Place top-level AND/OR | To begin | |||
GROUP BY and ORDER BY clause | Wrap elements | chop | ||
Subquery | Place Subquery | Same line aligned | ||
Place the closing parenthesis | To begin | |||
Put spaces within parentheses | ☑️ |
2.Expressions(表达式)
设置完这些代码已经呈现出比较整齐的状态了,后续还会更新。。。。
更多推荐
已为社区贡献1条内容
所有评论(0)