# Configure the SQL code style

Procedure: Enable the Database Tools and SQL plugin

This functionality relies on the  Database Tools and SQL plugin, which  is bundled and enabled in IntelliJ IDEA   by default. If the relevant features are not available, make sure that you did not disable the plugin.

> **Note:**
> Database Tools and SQL functionality support is limited in IntelliJ IDEA without the Ultimate subscription.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

You can apply and customize the SQL code style that satisfies code guidelines of your company.

To see the description of SQL style options, refer to [Code Style. SQL](settings-code-style-sql.html).

Procedure: Change code style settings

Customize formatting rules for the SQL code: alignment, wrapping, and indentation.

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | Code Style | SQL`.

2. Expand the SQL node and select a dialect.

3. Select all the necessary code style settings on the available tabs.

4. Click Apply.

![Code style settings](https://resources.jetbrains.com.cn/help/img/idea/2026.2/editor_code_style_sql.png)

> **Tip:**
> When you apply the rule, IntelliJ IDEA updates the SQL code and highlights all modified parts in the preview pane.

Procedure: Create a code style for a dialect

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | Code Style | SQL`.

2. Expand the SQL node and select a dialect.

3. Click the Show Scheme Actions icon (![The Show Scheme Actions icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.settings.svg)), and select Duplicate.

4. Type a name for a new style, and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

5. Select all the necessary code style settings, and click Apply.

![Create a code style for SQL](https://resources.jetbrains.com.cn/help/img/idea/2026.2/create_code_style.png)

Procedure: Configure code styles per data source

After you created a style for a dialect, you can apply this style to the data source that uses this dialect.

1. Right-click a data source and select Properties.

2. Click the Options tab.

3. In the Code style drop-down menu, select a style that you want to apply.

4. Click Apply.

![Configure code styles per data source](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_apply_code_style_to_data_source.png)

Procedure: Import code style settings

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | Code Style | SQL`.

2. Expand the SQL node and select a dialect.

3. Click the Set from… link and select the style that you want to import.

You can select preconfigured styles like Modern, Joe Celko  Allman (DDL only) ,  Whitesmiths (DDL only) ,  Egypt, Old Idea. Or, import settings from the dialect that you configured.

![Import code style settings](https://resources.jetbrains.com.cn/help/img/idea/2026.2/import_code_style_settings.png)

Procedure: Apply code style to the Generic dialect

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Code Style | SQL | SQL:2016, Generic`.

2. Clear the Inherit <a href="General">General SQL Style</a> checkbox.

3. Apply code style settings. For more information about code style settings, refer to [Code Style. SQL](settings-code-style-sql.html).

![Apply code style to the Generic](https://resources.jetbrains.com.cn/help/img/idea/2026.2/code_style_for_generic.png)

Procedure: Disable SQL formatting

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | Code Style | SQL | General`.

2. Select the Disable formatting checkbox.

3. Click OK to apply the changes.

![Disable SQL formatting in the editor](https://resources.jetbrains.com.cn/help/img/idea/2026.2/settings_code_style_sql_disable_sql_formatting.png)

## Apply the original case from the declaration

IntelliJ IDEA can format names of variables, procedures, and functions as you defined them initially. For example, if you defined the `get_Amount` function in the `CREATE PACKAGE` statement, you want the same case throughout your code, not `GET_AMOUNT` or `get_amount`.

To apply this case throughout the file, IntelliJ IDEA must find the declaration of these variables, procedures, and functions (for example, in the `CREATE PACKAGE` statement). To apply the case in multiple files, create [a DDL data source](ddl-data-sources.html) from these files.

Procedure: Apply the declaration case for a file

1. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | SQL`.

2. Select the dialect in which you want to apply the original case from the declaration.

3. Click the Case tab and select the Use original case checkbox.

4. Click OK.

5. Click `Code | Reformat Code` or press `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Alt+Shift+F` (NetBeans), `Ctrl+Alt+Enter` (Visual Studio), `⌘ ⌥ ⏎` (Visual Studio (macOS)), `Ctrl+Alt+L` (Eclipse), `⌘ ⇧ F` (Eclipse (macOS)).

On the following image, you can see `Pack_1.sql` and `Pack_2.sql` with identical code. `Pack_1.sql` is not reformatted. `Pack_2.sql` was reformatted with the Use original case checkbox enabled. In `Pack_2.sql`, the case from the package declaration was applied throughout the whole file.

![Enable the declaration case for a file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/db_enable_declaration_case_for_file.png)

Procedure: Apply the declaration case in multiple files

1. Create [a DDL data source](ddl-data-sources.html) from the files for which you want to apply the declaration case.

2. Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | SQL`.

3. Select the dialect in which you want to apply the declaration case settings.

4. Click the Case tab and select the Use original case checkbox.

5. Click OK.

6. Click `Code | Reformat Code` or press `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Alt+Shift+F` (NetBeans), `Ctrl+Alt+Enter` (Visual Studio), `⌘ ⌥ ⏎` (Visual Studio (macOS)), `Ctrl+Alt+L` (Eclipse), `⌘ ⇧ F` (Eclipse (macOS)) to apply the declaration case in any file of the DDL data source.

