CLion 2024.3 Help

Query results

Usually, when you run a query, you receive results in a table format. CLion displays the results in a data editor. For each statement, the data editor with results appears in a separate tab in the Services tool window. For example, if you run three SELECT statements in the query console, you will see three tabs in the tool window.

The results of the SELECT statements in the tabs of Services tool window

The data editor and viewer, or data editor, provides a user interface for working with data. In the data editor, you can sort, filter, add, edit, and remove the data as well as perform other associated tasks. For full information about data editor, refer to the Data Editor Dialog topic.

For more information about query consoles and Services tool window, refer to Query consoles and Services tool window.

Result tabs

Open a new tab for each new query

By default, CLion updates the same tab with results each time you run a new query after the previous one. You can change this behavior and create a tab each time you run a new query.

  1. In the IDE settings Ctrl+Alt+S, go to Tools | Database | Query Execution.

  2. Select the Open results in new tab checkbox and click OK.

Use custom titles for tabs with results

You can define a tab title in the comment section before the query. In the Treat text as title after field, you can reserve a combination of symbols or characters after which any text will be treated as a tab title. By default, no combination is used, so any text after -- or /* is treated as a tab title.

  1. Open settings by pressing Ctrl+Alt+S, navigate to Tools | Database | Query Execution | Output and Results.

  2. In the Treat text as title after field, define a combination for tab titles.

    To disable this feature, open settings Ctrl+Alt+S, navigate to Tools | Database | Query Execution | Output and Results, and clear the Create title for results from comment before query checkbox.

    For more examples of custom titles for tabs, refer to Name the result tabs at youtube.com.

    Use custom titles for tabs with results

Pin the tab with query results

If one and the same tab is used to show your query results, and you get the result that you want to keep, you can pin the tab to the tool window.

  • Right-click the tab and select Pin Tab.

    Pin the result tab

In-Editor Results

You can also view the query results within the editor. To do that, use the In-Editor Results feature.

  • To toggle the In-Editor Results feature for the current file, click the In-Editor Results button (the In-Editor Results icon) on the toolbar.

    Enable in-editor results for the current file
    Disable in-editor results for the current file
  • To toggle the In-Editor Results feature for all files across the IDE, open settings by pressing Ctrl+Alt+S and navigate to Database | Query Execution | Output and Results | Results. Clear the Show results in editor checkbox.

Result sets

View two result sets in the editor

  • Click the In-Editor Results button (the In-Editor Results icon) on the toolbar to view the result sets one above the other.

    View two result sets in the editor

Edit values in the result set

  1. In the result set, click a cell value that you want to edit.

  2. Specify a new value and press Enter.

  3. To submit changes to a database, click the Submit button (the Submit icon) on the toolbar, or press Ctrl+Enter.

    For more information about submitting changes to a database, refer to the Submit changes to a database topic.

    Modify values in the result set

Compare two result sets

  1. Run queries to tables that you want to compare.

  2. In the Services tool window, click the Compare Data button (The Compare with icon), and select the result set that you want to add to diff.

  3. If needed, change a value of the Tolerance parameter in the comparison dialog. The Tolerance parameter defines a maximum number of differences that are allowed between two result sets. For example, if you want to consider two rows as equal if their data differs in a single column, enter 1 in the Tolerance field.

    See another example of comparing two result sets in Compare data at youtube.com.

Output tab

View query log

On the Output tab in the Services tool window, you can see a log of user and internal queries.

  1. In the Database tool window (View | Tool Windows | Database) , , open a query console by right-clicking a data source and navigating to New | Query Console.

    Alternatively, select a data source and press F4.

  2. Run a query.

  3. In the Services tool window that opens, click the Output tab.

Services tool window reference

For more information about tool window controls and tabs, refer to the the Services tool window topic.

Database services in the Services tool window
Last modified: 31 October 2024