WebStorm 2021.1 Help

Query results

Usually, when you run a query, you receive results in a table format. Each statement appears in a separate tab in the Services tool window. For example, if you have two SELECT statements in the query, you will see two tabs in the tool window.

The Services tool window includes a list of consoles that are grouped according to a connection session to a data source.

Open a new tab for each query

By default, WebStorm updates the same tab with results each time you run a query. You can change this behavior and create a tab each time you run a query.

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

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

View two result sets in the editor

  • Click the In-Editor Results button to view result sets one above another.

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 | General.

  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 | General, and clear the Create title for results from comment before query checkbox.

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

    Use custom titles for tabs with results

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 icon (The Submit icon), or press Ctrl+Enter.

    Modify values in the result set

Export to a file

  1. To export data to a file, perform one of the following actions:

    • Right-click a result set, a table, or a view, select Export Data.

    • Right-click a query and select Export Data to {0,choice, 1#File|2#Files}.

    • On the toolbar, click the Export Data icon (The Export Data icon) and select Export to File.

  2. In the Export Data dialog, click Export to File.

Export to a clipboard

  • Select data in the result set or in the editor and press Ctrl+C.

  • On the toolbar, click the Export Data icon (The Export Data icon) and select Copy To Clipboard.

Compare two result sets

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

  2. In the Services tool window, click the Compare with icon (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.

    Compare result sets

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

Sort data

Click the column name to sort the column data. The column sorting is not stacked by default. It means that if you click a column name to sort data by, the sorting based on other columns will be cleared. If you prefer to use the stacked sorting, click a column name while pressing Alt.

stacked sorting
StateDescription
No sortingIndicates that the data is not sorted in this column. The initial state of the sorting marker.
Ascending orderThe data is sorted in the ascending order. The number to the right of the marker (1 on the picture) is the sorting level. You can sort by more than one column. In such cases, different columns will have different sorting levels.
Descending orderThe data is sorted in the descending order.

    Operations with columns in the structure view

    The structure view displays you a list of all the columns in the selected table. The structure view is available in the Structure tool window (View | Tool Windows | Structure) or in the popup window (Ctrl+F12).

    You can perform the following operations with columns:

    • Sort the data in the ascending Alt+Shift+Up or the descending order (Alt+Shift+Down).

    • Reset the state of sorting ( select Sort | Unsorted in the tool window)

    • Hide a column or show a hidden column (Space). The names of hidden columns are shown struck-through.

      Operations with columns in the structure view

    Copy data to another database

    1. Double-click a table to open it in the data editor.

    2. Click the Copy to Database icon on the toolbar.

    3. Specify the database, target schema (to create a new table with the exported data) or table (to add exported data to an existing table).

    4. Configure the data mapping and settings for the target table.

      Copy data to another database

    Edit data in INSERT statements as a table

    1. Select INSERT statements that you want to edit.

    2. Right-click the selection and click Edit as Table.

      Edit data in INSERT statements as a table

    Logging SQL activity

    Change location of the SQL log

    To change location of the SQL log, add the -Didea.system.path property to the custom VM options. This change affects all logs.

    1. Click Help | Edit Custom VM Options.

    2. At the end of the option list, add the following line: -Didea.system.path=/path/to/your_log_directory.

    Change location of the SQL log
    Last modified: 24 June 2021