Tips & Tricks

Top 10 IntelliJ IDEA Shortcuts for Efficient Data Querying With the Database Tools

Thanks to the dedicated SQL query console inside IntelliJ IDEA Ultimate’s Database Tools, you can easily modify and extract data from any database connected to your Java application without ever leaving the IDE. The query console comes with an SQL statement-specific code snippets library, code completion, on-the-fly error detection, and useful shortcuts – all to help you stay in the flow.

Get IntelliJ IDEA Ultimate

In this article, we’ll share the top 10 shortcuts for working with Database Tools, which will enhance your productivity while querying data.

Open a new console: ⌘⇧L | Ctrl+Shift+Q

Simply select a Data source in the Database tool window and press these three keys to open a new console – ⌘⇧L (macOS) or Ctrl+Shift+Q (Windows/Linux).

Open a new console by shortcuts ⌘⇧L | Ctrl+Shift+Q

There might be a conflict with the Google Chrome shortcut – deactivate it through your System Settings keyboard shortcuts.

Execute statement: ⌘↩ | Ctrl+Enter

To quickly execute the entire statement or a selected part of code, press ⌘↩ (macOS) or Ctrl+Enter (Windows/Linux).

When multiple statements are selected, you can choose which statement to execute from the Statements popup menu. The selected statements are highlighted in the query editor, making it easy to review and confirm your choice.

Execute statement by shortcuts ⌘↩ | Ctrl+Enter

Invoke intention actions: ⌥↩ | Alt+Enter

IntelliJ IDEA analyzes your code and provides you with ways to optimize it, detects potential problems, and suggests fixes for them. To call a list of suggestions and fixes for queries, press ⌥↩ (macOS) or Alt+Enter (Windows/Linux).

Invoke intention actions by shortcuts ⌥↩ | Alt+Enter

Open a list of live templates: ⌘J | Ctrl+J

IntelliJ IDEA has an extensive library of code templates to speed up compilation of SQL queries. Press ⌘J (macOS) or Ctrl+J (Windows/Linux) to access a list of live templates for queries.

You can also add your own templates through Settings | Editor | Live Templates by pressing ⌘N (macOS) or Ctrl+N (Windows/Linux).

Open a list of live templates by shortcuts ⌘J | Ctrl+J

Recent files: ⌘E | Ctrl+E

Accidents happen, and you might have unintentionally closed a tab containing a complex SQL query. There is no need to worry, as you can reopen the file with just two keystrokes from the Recent files list – ⌘E (macOS) or Ctrl+E (Windows/Linux).

Recent files by shortcuts ⌘E | Ctrl+E

Reformat code: ⌥⌘L | Ctrl+Alt+L

Clean and organized code is essential for productive development, and IntelliJ IDEA’s code formatting capabilities are here to help. To reformat a selected code fragment or the whole file within the query console tab, press ⌥⌘L (macOS) or Ctrl+Alt+L (Windows/Linux).

You can customize SQL formatting to your coding style via Settings | Editor | Code Style | SQL. Here, you can format rules for statements, tables, expressions, and much more.

Reformat code by shortcuts ⌥⌘L | Ctrl+Alt+L

Paste from clipboard history: ⇧⌘V | Ctrl+Shift+V

In IntelliJ IDEA, every piece of code or text you copy is saved to the clipboard and can be accessed throughout your working session. Press ⇧⌘V (macOS) or Ctrl+Shift+V (Windows/Linux) and select the item from the list.

Paste from clipboard history by shortcuts ⇧⌘V | Ctrl+Shift+V

Rename refactor: ⇧F6 | Shift+F6

Place the caret on the object you want to rename and press ⇧F6 (macOS) or Shift+F6 (Windows/Linux) to call the Rename dialog, where you can also adjust the scope of a change and preview it before actual renaming.

Rename refactor by shortcuts ⇧F6 | Shift+F6

Generate code snippets: ⌘N | Alt+Insert

Press ⌘N (macOS) or Alt+Insert (Windows/Linux) to call a Generate popup within the query console. There, you can choose a snippet from a vast selection of statements.

Generate code snippets by shortcuts ⌘N | Alt+Insert

Generate code with AI: ⌘\ | Ctrl+\

AI Assistant can generate SQL queries for you directly in the query console. Invoke it by pressing ⌘\ (macOS) or Ctrl+\ (Windows/Linux) in the field, type the query you want AI Assistant to compile, and submit your request by pressing ↩︎/Enter.

Generate code with AI by shortcuts ⌘\ | Ctrl+\

Integrate these shortcuts to boost your daily productivity and stay in the flow. Visit this page to learn more about IntelliJ IDEA’s Database Tools features.

Happy developing!

Shortcuts cheat sheet

ActionmacOSWindows/Linux
Open a new console⌘⇧LCtrl+Shift+Q
Execute statement⌘↩Ctrl+Enter
Invoke intention actions⌥↩ Alt+Enter
Open a list of live templates⌘J Ctrl+J
Recent files⌘ECtrl+E
Reformat code⌥⌘LCtrl+Alt+L
Paste from clipboard history⇧⌘VCtrl+Shift+V
Rename refactor⇧F6Shift+F6
Generate code snippets⌘NAlt+Insert
Generate code with AI⌘\Ctrl+\
image description