Queries
Configure code style for INSERT, UPDATE, WITH, SELECT, FROM, and other query structures.
Common
Item | Description | ||||||
---|---|---|---|---|---|---|---|
Align the first word of clause | Align keywords to the left or right margin of the first word of a statement section (for example, SELECT). The To left with indent option aligns all keywords except for WITH, UNION, and INTERSECT along the left margin with the indent.
| ||||||
Place clause elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). | ||||||
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. | ||||||
Collapse short statements | Join multiline short statements. The length of a statement that will be collapsed is determined automatically by DataGrip. To enable this option only for subqueries, select Subqueries only. | ||||||
Keep section elements under section header | Move all section elements under the section main keyword (a header). | ||||||
Align section elements | Align elements of a clause section.
| ||||||
Align line comments at right of elements | Align line comments that are on the right side of code. |
INSERT statement and VALUES clause
Item | Description | ||||
---|---|---|---|---|---|
Place INTO on the new line | Move INTO and clause elements that follow INTO on a new line. | ||||
Place INTO clause elements on | Move clause elements that follow INTO on a new line. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. | ||||
Place VALUES clause elements (rows) on | Move clause elements that follow VALUES on a new line. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. | ||||
Place the opening parenthesis | Align or indent the opening parenthesis under the first keyword on the line. Select On the same line to keep the opening parenthesis on the line with the keyword. | ||||
Place columns or values | Change the position of elements in relation to the opening parenthesis.
| ||||
Place the closing parenthesis | Change the position of the closing parenthesis.
| ||||
Wrap columns or values | Move objects to a new line.
| ||||
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab.
The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. . | ||||
Put spaces within parentheses | Add a space after the opening parenthesis and before the closing parenthesis. | ||||
Collapse short multi-row values | Place all statements on a single line. |
UPDATE statement
Item | Description |
---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap elements | Move elements to a new line.
|
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Align `=` | Align all equal signs ( |
WITH clause
Item | Description | ||||||
---|---|---|---|---|---|---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. | ||||||
Wrap subqueries | Move elements to a new line.
| ||||||
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. The In the middle option joins two lines of code on one line. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. The Place comma option works only if the Wrap subqueries option in the WITH clause section is set to Chop or Chop if long. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab.
| ||||||
Align AS | Align all AS keywords. |
SELECT clause
Item | Description |
---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap elements | Move elements to a new line.
|
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
New line after ALL, DISTINCT | Add a new line after ALL and DISTINCT. |
Keep elements on one line if ≤ | Set the maximum number of elements on one line. |
Use AS | Always use AS for aliases. |
Align AS | Align all AS keywords. |
FROM clause
Item | Description |
---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap elements | Move elements to a new line.
|
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap the first JOIN | Move the first JOIN in the SELECT statement to a new line. |
Wrap the next JOIN | Move the second JOIN in the SELECT statement to a new line. |
Indent JOIN | Add an indent before the JOIN clause. |
Place JOIN in join-only queries under | Select the element according to which you want to align the JOIN clause.
|
Align joined tables | Align table names in JOIN clauses. |
Align table aliases | Align table aliases in JOIN clauses. |
Wrap ON/USING | Move ON and USING to a new line. |
Place ON/USING under | Align ON and USING to the table name (Table), or align to the table name and add an indent (Table indented). |
WHERE and HAVING clauses
Item | Description |
---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap elements | Move elements to a new line.
|
Place top-level AND/OR | Move AND and OR to the end (To end) or to the beginning (To begin) of a clause. |
Align AS | Align all AS keywords. |
GROUP BY and ORDER BY clauses
Item | Description |
---|---|
Place elements on | Move clause elements to a new line (New line) or leave them on the same line (Same line). The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Wrap elements | Move elements to a new line.
|
Place comma | Move a comma ( The Auto option analyzes the surrounding context and calculates the most suitable place for a comma. For example, you have three occurrences of a comma: two commas go at the beginning, one comma is at the end. The Auto option will move the third occurrence of the comma to the beginning. This option works only if you have more than three cases in a single context. Otherwise, commas are left as is. If you want to disable a new line after the comma when the To begin option is enabled, clear the Line breaks checkbox on the Wrapping tab. The As in common option means that the behavior of the selected option must duplicate the behavior of the analogous option in the Common section on the Queries tab. |
Align ASC/DESC | Align all ASC and DESC keywords. |
Subquery
Item | Description |
---|---|
Place the opening parenthesis | Align or indent the opening parenthesis under the first keyword on the line. Select On the same line to keep the opening parenthesis on the line with the keyword. |
Place subquery | Change the position of elements in parentheses.
|
Place the closing parenthesis | Change the position of the closing parenthesis.
|
Put spaces within parentheses | Add a space after the opening parenthesis and before the closing parenthesis. |