DataGrip|SQL 自动格式化常用配置(完整版)

这篇具有很好参考价值的文章主要介绍了DataGrip|SQL 自动格式化常用配置(完整版)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

版本:DataGrip 2023.2.1

配置方法:Settings > Code Style > SQL > General(或其他语言)

Case 通用

Word Case 单词大小写设置
  • Keywords:关键字大小写设置(例如 SELECTWHEREAS 等)
  • Identifiers:标识符大小写设置(例如表名、列名等)
  • Built-in types:内置类型大小写设置(例如 INTVARCHAR 等)
  • Custom types:用户类型大小写设置
  • Aliases:别名大小写设置
  • Build-in functions:内置方法的大小写设置(例如 COUNTCASE 等)
  • Quoted identifiers:引用的标识符(例如用引号括起来的表名、列名等)
  • Use original case:
Quotation 引号设置
  • Identifier quotation:标识符前后的引号设置
    • Unquote:去除标识符前后的引号(但是当已被引号括起来的标识符中包含空格等字符时,不会去除)
    • Quote:在标识符前后添加引号
  • Quotation character:引号符号设置

Queries 查询语句

Common:通用
  • Align the first word of clause:是否将所有子句的左侧对齐
  • Place clause elements on :将子句放在关键字之后的什么位置
  • Place comma:将每一行的逗号放置在什么位置(行首或行尾)(DataGrip 在将原本至于行首的格式化为行尾时,会出现很多异常,很不稳定
  • Collapse short statement:是否折叠短的表达式
  • Keep section elements under section header:
  • Align section elements:
  • Align line comments at right of elements:对齐每一行之后的注释(在格式化之前,每行注释之前必须有大于等于 1 个空格),包括字段后的注释等
INSERT statements and VALUES clause:INSERT 表达式和 VALUES 字句
  • Place INTO on the new line:将 INTO 关键字放到什么位置
  • Place INTO clause elements on :
  • Place VALUES clause elements (rows) on:
  • Place the opening parenthesis:
  • Place columns or values:
  • Place the closing parenthesis:
  • Wrap columns or values:
  • Place comma:
  • Spaces within parentheses:
  • Collapse short multi-row values:是否折叠短的多条待插入数据
UPDATE statement:UPDATE 表达式
  • Place elements on:
  • Wrap elements:
  • Place comma:
  • Align =:是否将各个字段的 = 对齐
WITH clause:WITH 字句
  • Place elements on:
  • Wrap subqueries:
  • Place comma:
  • Align AS:是否将各个中间表的 AS 对齐
SELECT clause:SELECT 字句
  • Place elements on:
  • Wrap elements:
  • Place comma:
  • New line after ALL, DISTINCT:
  • Keep elements on the one line if <=:
  • Use AS:是否使用 AS 或省略
  • Align AS:是否对齐所有的 AS
  • Treat asterisk as a regular element:
FROM caluse:FROM 字句
  • Place elements on:第一个表名是跟在 FROM 关键字之后还是另起一行
  • Wrap elements:FROM 字句是否换行
  • Place comma:多个表时逗号的位置
  • Wrap the first JOIN:第一个 JOIN 字句是否换行
  • Wrap the next JOIN:除第一个外的其他 JOIN 字句是否换行
  • ident JOIN:在每个 JOIN 字句前是否加额外的空格
  • Place JOIN in join-only queries under
  • Align joinedtables:是否对其每 join 字句中的表名
  • Align table aliases:
  • Wrap ON/USING:是否在 ON 和 USING 之前换行
  • Place ON/USING under:如果 Wrap ON/USING 开启的话,将 ON/USING 语句与什么对齐
WHERE and HAVING clauses:WHERE 和 HAVING 字句
  • Place elements on:第一个 WHERE 条件是跟在 WHERE 关键字之后还是另起一行
  • Wrap elemnts:括号中的条件是否换行?
  • Place top-level AND / OR:如何防止最上一层的 AND 和 OR 关键字
    • begin:每行的开头位置
    • end:每行的结尾位置
GROUP BY and ORDER BY clauses:GROUP BY 和 ORDER BY 字句
  • Place elements on:
  • Wrap elements:
  • Place comma:
  • Align ASC / DESC:
Subquery:子查询
  • Place the opening parenthesis:如何放置子查询的左括号

  • Place subquery:如果放置子查询的主体(即 SELECT 关键字)

  • Place the closing parenthesis:如何放置子查询的右括号

    • Under opening:与左括号的列对齐(新起一行)
  • Space after keyword:在子查询前的关键字(例如 FROM、IN、EXISTS) 之后是否添加空格

  • Spaces within parentheses:在子查询的括号之间是否添加空格文章来源地址https://www.toymoban.com/news/detail-812170.html

DDL 数据定义语言

CREATE TABLE
  • Place the opening parenthesis:如何放置左括号
  • Place elements:
  • Place the closing parenthesis:如何放置右括号
  • Collapse when short:当建表语句很短时是否折叠为一行
ALTER TABLE
  • Wrap altering instructions:
  • INdent altering instructions
  • Align altering instructions
  • Wrap altered items
  • Indent altered items
  • Align altered items
CREATE or ALTER TABLE
  • Align types:是否对齐各个字段的类型
  • Align defaults:是否对齐各个字段的 defaults 部分
  • Align nullabilities:是否对齐各个字段的 NOT NULL 部分
CONSTRAINT
  • Wrap CONSTRAINT:
  • Wrap KEY/CHECK:
  • Wrap REFERENCES:
  • Wrap cascade and deferrability:
CREATE SCHEMA
  • Indent content:
  • Minimum blank lines between declaration
  • Maximum blank lines between declaration
Views
  • Wrap AS:是否对齐各个字段的 AS
  • Wrap the beginning of the query:
  • Indent query
Postfix options
  • Wrap first option:
  • Wrap next option:vpt
  • Indent options:
  • Align options:

Code

Script
  • Wrap command-ending semicolon:
  • Commands follow by blank lines:
Impreative Commons
  • Wrap every statement
  • Keep blank lines in code
Declared variables
  • Wrap section
  • Wrap variables
  • Align types
  • Align assignments
  • Align expressions
Routine arguments
  • Place the opening parenthesis
  • Place elements
  • Place the closing parenthesis
  • Wrap elements
  • Place comma
  • Spaces within parentheses
  • Align types
Routine statement
  • Wrap AS
  • Wrap opening $$
  • Wrap the content after opening $$
  • Wrap before closing $$
  • Wrap options after closing $$
IF … THEN … ELSE
  • Wrap THEN
  • Wrap ELSE
  • Wrap inner code
  • indent THEN and ELSE
  • indent END IF
  • Collapse when short:当整个 IF ... THEN ... ELSE 语句很短时,是否折叠为一行
Loops
  • Wrap LOOP
  • Indent Loop
  • Indent END LOOP
  • Collapse when short

Expressions

Cortege
  • Add space before (
  • Space within parentheses
  • Place comma to begin
  • Space before comma
  • Space after comma
Binary expression
  • Use spaces around operators
  • Align operands in binary expressions
  • Space within parenthesized sub-expressions
Function or procedure call
  • Space within parentheses
  • Space before comma
  • Space after comma
CASE clause:CASE 从句
  • Wrap WHEN:是否在第一个 WHEN 关键字之前换行
  • Indent WHEN if wrapped:如果在第一个 WHEN 关键字之前换行,是否在 WHEN 关键字之前缩进
  • Wrap THEN:是否在 THEN 关键词之前换行
  • Align THEN:是否对齐 THEN 关键字
  • Align ELSE under THEN when THEN aligned:如果 THEN 关键字对齐,那么 ELSE 是否与 THEN 对齐(否则与 WHEN 对齐)
  • Align END:如何将 END 对齐
  • Keep new line after THEN, ELSE
  • Collapse short clause:是否压缩较短的 CASE 从句

Tabs and Indents

  • Use tab character:是否使用制表符(\t
  • Tab size:Tab(制表符)对应的半角字符数
  • Indent:缩进的半角字符数
  • Continuation indent
  • Keep indents on empty lines

Wrapping

Keep when reformatting
  • Line breaks
  • Comment at first column

到了这里,关于DataGrip|SQL 自动格式化常用配置(完整版)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • vscode自动格式化插件配置说明(Prettier - Code formatter)

    1、在应用商店搜索Prettier并下载 2、下载完成之后点击扩展设置  3、点击右上角json配置文件  4、在文件中添加如下代码 5、如果需要格式化vue文件,建议配合ESLint、Vetur两个插件一起使用  一款好用的eslint自动修复插件:eslint-config

    2024年02月12日
    浏览(41)
  • VScode自动格式化代码(tab缩进、符号空格)配置beautify插件使用

    安装插件 在插件库搜索beautify,会弹出很多插件 你需要根据你自己的语言选择对应的插件安装,尽量选择在维护中的插件 我是做前端的,所以选择的是beautify blade,格式化语言:javascript, JSON, CSS, Sass, and HTML ![在这里插入图片描述](https://img-blog.csdnimg.cn/cc42b7d4f0b549a78d16c69e7d33

    2024年02月12日
    浏览(35)
  • 【常用的简单功能及算法】拦截器 加盐算法 深克隆 时间日期格式化 加盐算法 sql分页算法 验证码

    1.实现拦截器 Interceptor (以登录拦截器为例) 1.1 写一个登录拦截器普通类 实现HandlerInterceptor接口 重写preHandle方法 2.2 设置拦截规则 加@Configuration注解 实现WebMvcConfigurer接口 重写addInterceptors方法 2.深克隆方法 (spring提供的深克隆方法) 3.时间日期格式化  1. 全局日期格式化 这种

    2024年01月21日
    浏览(31)
  • Java ORM Bee 2.1.7 解决缓存雪崩问题,sql 格式化,配置 Sharding 执行线程池大小

    Bee, 开发 JavaWeb 数据库应用首选。既想得到 NoSQL 的性能,又想拥有关系型数据库事务的能力,用 ORM Bee, 即可轻松解决. Java ORM Bee 不但支持 JDBC 类型的数据库,还支持 Mongodb, 也支持 Android, 鸿蒙. Hibernate/MyBatis+ plus +Sharding JDBC + Jpa+ Spring data+ GraphQL+ App ORM (Android, 鸿蒙)= Bee V2

    2024年02月13日
    浏览(36)
  • vite初始化vue3项目(配置自动格式化工具与git提交规范工具)

    初始化项目 vite构建vue项目还是比较简单的,简单配置选择一下就行了 初始化命令 初始化最新版本vue项目 2. 基本选项含义 Add TypeScript 是否添加TS ADD JSX是否支持JSX ADD Vue Router是否添加Vue Router路由管理工具 ADD Pinia 是否添加pinia(状态管理工具) Add ESLinit 是否添加ESLint是否添加

    2024年02月12日
    浏览(47)
  • 第二章 React项目配置ESlint和Prettier实现自动格式化代码以及统一代码风格

    欢迎加入本专栏!本专栏将引领您快速上手React,让我们一起放弃放弃的念头,开始学习之旅吧!我们将从搭建React项目开始,逐步深入讲解最核心的hooks,以及React路由、请求、组件封装以及UI(Ant Design)框架的使用。让我们一起掌握React,开启前端开发的全新篇章! 需要准

    2024年02月03日
    浏览(45)
  • DBeaver中使用外部格式化程序对进行sql格式化

    本文介绍了如何在DBeaver中使用pgFormatter、sqlprase、sqlformatter等外部格式化程序对sql进行格式化。 目录 一、pgFormatter 1.准备工作 2.DBeaver中进行配置 二、sqlprase 1.准备工作 2.在DBeaver中配置 三、sql-formatter 1.准备工作 2.在DBeaver中配置 pgFormatter本质是perl脚本,所以需要perl运行环境支

    2024年01月25日
    浏览(39)
  • 在线SQL格式化工具

    工具地址:http://sql.wc139.com/ SQL格式化工具介绍 在线SQL格式化工具是一款针对SQL语句进行压缩与格式化的工具,可实现SQL语句的在线压缩与格式化功能,可运用于对复杂SQL语句的分析或者是程序代码优化上,只是清晰的结构,才能让您更好的优化数据库查询或写入。 关于SQL介绍

    2024年02月03日
    浏览(31)
  • SQL Server日期格式化

    一、时间戳的生成 使用dateDiff方法,运算当前时间到标准时间之间的秒数。 DATEDIFF(s,‘1970-01-01 00:00:00’, getdate()) 二、日期格式转换 使用convert(data_type,source_data,style)进行格式转换。利用style控制转换格式。 结果: CONVERT(nvarchar(80),getdate(),0)----07 27 2022 8:33AM CONVERT(nvarchar(80),getd

    2024年02月06日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包