马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
版本:DataGrip 2023.2.1
配置方法:Settings > Code Style > SQL > General(或其他语言)
Case 通用
Word Case 单词巨细写设置
- Keywords:关键字巨细写设置(比方 SELECT、WHERE、AS 等)
- Identifiers:标识符巨细写设置(比方表名、列名等)
- Built-in types:内置类型巨细写设置(比方 INT、VARCHAR 等)
- Custom types:用户类型巨细写设置
- Aliases:别名巨细写设置
- Build-in functions:内置方法的巨细写设置(比方 COUNT、CASE 等)
- 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:在子查询的括号之间是否添加空格
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
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |