Code Style. SQL
for macOS
Use this page to configure formatting options for SQL files. View the result in the Preview pane on the right.
General
Use this tab to specify certain formatting behaviors in your code. The results are displayed in the Preview pane.
Item | Description |
---|---|
Word Case | In this node, specify whether the keywords, identifiers, or quoted identifiers case should change automatically. Click the right-hand column, and check the desired behavior on the menu to turn it on. The possible options are:
|
Identifier quotations | Click the right-hand column, and check the desired behavior on the menu to turn it on. The possible options are:
|
New line before/after | Use these nodes to define how many blank lines you want DataGrip to retain and insert in your code after reformatting. For each type of SQL element, select of clear the checkbox to the right. The results are highlighted in the Preview pane. |
New line around semicolon | Use this checkbox to manage line delimiters around a semicolon. |
Alignment | Select the checkboxes next to the desired elements of source code to have them automatically aligned. |
Tabs and Indents
Item | Description |
---|---|
Use tab character |
|
Smart tabs |
The Smart Tabs checkbox is available if the Use Tab Character checkbox is selected. |
Tab size | In this field, specify the number of spaces included in a tab. |
Indent | In this field, specify the number of spaces (or tabs if the Use Tab Character checkbox is selected) to be inserted for each indent level. |
Continuation indent | In this field, specify the number of spaces (or tabs if the Use Tab Character checkbox is selected) to be inserted between the elements of an array, in expressions, method declarations and method calls. |
Keep indents on empty lines | If this checkbox is selected, then DataGrip will keep indents on the empty lines as if they contained some code. |
Spaces
Use this tab to specify where you want spaces in your code. To have DataGrip automatically insert a space at a location, select the checkbox next to this location in the list. The results are displayed in the Preview pane.
Wrapping and Braces
In this tab, customize the code style options, which DataGrip will apply when reformatting the source code. The left-hand pane contains the list of exceptions (Keep when reformatting), and placement and alignment options for the various code constructs (lists, statements, operations, annotations, etc.). The right-hand pane shows preview.
Alignment takes precedence over indentation options.
Item | Description |
---|---|
Keep When Reformatting | Use the checkboxes in this node to configure exceptions that DataGrip will make when reformatting the source code. For example, by default, the Line brakes checkbox is selected. If your code contains lines that are shorter than a standard convention, you can convert them by disabling the Line brakes check box before you reformat the source code. |
Wrap inside | Use this node to define wrapping style for the lengthy elements. |
Values expression | Use this option to define wrapping style for values expressions. You can use different wrapping style options that are available from the drop-down list in the left-hand pane. |
Wrapping Style Options | The wrapping style applies to the various code constructs, specified in the left-hand pane (for example, expressions, or assignment statements). From the drop-down list, select the desired wrapping style:
|
Blank Lines
Use this tab to insert blank lines into your code.
Item | Description |
---|---|
Keep Maximum Blank Lines | Use this area to specify blank lines in your code. |
Code Generation
The tab contains templates for the names of primary and foreign key constraints, and indexes. These templates are used to generate default names for the constraints and indexes when you create them in the Create Table or the Modify Table dialog.
The templates can contain variables and text. When you generate a name, the specified text is reproduced literally. For example, when you apply the {table}_pk
template in the actor
table, the generated name of the primary key will be actor_pk
.
To see information about possible variables and their usage, place the cursor into a field and press Ctrl+Q.
{unique?u:}
checks if the index is unique and inserts the corresponding sequence of characters. If the index is unique, the template generates a name with the sequence of characters specified between ?
and :
. For the {unique?u:}
template, it is u
. If the index is not unique, the sequence between :
and }
is inserted. For the {unique?u:}
template, it is nothing.
You have the persons
table with columns FirstName
and LastName
. The {table}_{columns}_{unique?u:}index
template generates the following name for the not unique index: persons_FirstName_LastName_index
.
Set from...
Click this link to reveal the list of languages to be used as the base for the current language code style. Only the settings that are applicable to the current language are taken. All the other settings are not affected.
This link appears in the upper-right corner of the language-specific code style page, when applicable.
Click Reset to discard changes and return to the initial set of code style settings.