Back to JetBrains

DataGrip Overview, Part 4: Running Queries

JetBrainsOctober 14, 20263m
In a Nutshell

DataGrip runs queries based on cursor position without needing explicit selection, with a customizable popup for choosing current query, entire script, or smallest query. Results appear in the Services tool window with tabs that can be named via preceding comments, and you can view explain plans in tree or graph mode. Query duration shows in tooltips, and results can display inline below each query within the editor.

AI-Generated Notes

These notes were generated by AI and may contain inaccuracies.

When running queries in DataGrip, you don't need to specify the code because DataGrip understands where your typing pointer is. If the file contains multiple queries, DataGrip will present you with a selection tool so that you can run the current query or the entire script. This means you don't need to specify the queries to run them, although that method also works. Note that subqueries and common table expressions are also available as run options, making it easier to debug queries with these structures.

This behavior is customizable. To go to settings, click on "Customize" at the bottom of the selection tool. Here, you can specify whether the selection tool will actually appear and assign three different shortcuts for three different behaviors. One of the most useful of these behaviors is running the smallest query that is under the writing cursor. You won't even need to choose anything.

The results are placed in the services tool window. On the left side of this window, there is a list of connections, each with its own node. You can adjust the services window layout by moving services to their own separate tool windows. Right-click on the service and select "open a new tab".

You can use the Output tab in the Services window to view information about SQL statements and other operations you performed on the query file. Also, the Output tab displays information about errors, timestamps, affected rows, query duration, autosave mode, and other operations.

Sign in to read the full notes

Get access to AI-generated notes, topic timestamps, and more.