PhpStorm 2018.3 Help

Working with Query Results

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

Open a new tab for each query

By default, PhpStorm 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 Database | General.

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

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.

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

Export to a file

  • Right-click a, select Dump Data | To File.

  • Right-click a query, click Execute to File and select the file type that you want to use for export (for example, Comma-separated (CSV)).

  • On the toolbar, click the Dump Data icon (The Dump Data icon) and select To File.

Export a view to a file

Export to a clipboard

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

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

Compare two result sets

  1. Select a result set.

  2. Click the Compare with icon (The Compare with icon), and select another result set.

  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.

Hiding or showing the toolbar

To hide or show the toolbar of the Result pane and also that of the Database Console tool window:

  • Click icons general gearPlain svg on the title bar of the Database Console tool window and click Show Toolbar.

Pinning the Result tab

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. Do one of the following:

  • Right-click the tab and select Pin Tab.

  • Click Pin button on the toolbar.

    ShowResultsInNewTabOFFPinTab

See also, Show query results in new tab .

Depending on the value of the Limit page size to parameter, the result set might be divided into several pages. For example, you set the Limit page size to parameter to 100, but your query returned 200 rows. You will have two pages of rows, with 100 rows on each page. To navigate between pages, use the following controls:

  • The first page icon: Navigates to the first page of the result set.

  • The previous page icon: Navigates to the previous page of the result set. ( Ctrl+Alt+Up )

  • The next page icon: Navigates to the next page of the result set. ( Ctrl+Alt+Down )

  • Go to the last page icon: Navigates to the last page of the result set.

Making all rows visible simultaneously

If you want all the rows that satisfy the query to be shown simultaneously:

  1. Click icons general settings svg on the toolbar of the Database Console tool window.

  2. Switch to the Database | Data Views page, specify 0 in the Result set page size field, and click OK.

  3. Click icons actions refresh svg or press Ctrl+F5 to refresh the table view.

See also, Update the table view and Result set page size.

Go to the specified row

To navigate to a row with a specified number, right-click the table and select Go To | Row (Ctrl+G). In the Go to row dialog, specify the row number and click OK.

Go to a specified row

Navigate to a related object

You can retrieve rows from the table for the selected object, and move the focus to the object. For example, select a field in the project tree and press Ctrl+Alt+B. The focus moves to the corresponding column in the new tab.

To navigate to the object in the result set, select an object and go to Navigate | Related Symbol (Ctrl+Alt+B).

Navigate between related data

You can navigate between different types of related data:

  • Referenced data: data that is referenced by the current object.

  • Referencing data: data that is referencing the current object.

Referenced and referencing data
  1. Right-click the column in the table and navigate to Go To | Referenced Data (Ctrl+B) or Go To | Referencing Data (Ctrl+Alt+B).

  2. If the Choose target pop-up window appears, select the table and what rows to show:

    • First Referencing Row: all rows in the table. The first row that references the current row is selected.

    • Referencing Rows Only: only rows that reference the current row.

  3. Press Enter

Sorting data

To sort table data in a column, click the cell in the header row.

State

Description

No sorting

Indicates that the data is not sorted in this column. The initial state of the sorting marker.

Ascending order

The 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 order

The data is sorted in the descending order.

Reordering columns

To reorder columns, use drag-and-drop for the corresponding cells in the header row.

Hiding and showing columns

To hide a column, right-click the corresponding header cell and select Hide column.

To show a hidden column:

  1. Do one of the following:
    • Right-click any of the cells in the header row and select Column List.

    • PressCtrl+F12.

    In the list that appears, the names of hidden columns are shown struck through.

    TableResultPaneHideColumn
  2. Select (highlight) the column name of interest and press Space.

  3. Press Enter or Escape to close the list.

See also, Restoring the initial table view and Using the Structure view to sort data, and hide and show columns.

Restoring the initial table view

Click IconDBToolbarMenu on the toolbar and select Reset View to restore the initial table view after reordering or hiding the columns, or sorting the data. As a result, the data, generally, becomes unsorted, the columns appear in the order in which they were defined initially, and all the columns are shown.

Using the Structure view to sort data, and hide and show columns

When working with the Result pane, the table structure view is available as the corresponding popup.

The structure view shows the list of all the columns and lets you sort the data as well as hide and show the columns.

To open the structure popup, do one of the following:

  • Right-click a cell in the table header row and select Column List.

  • PressCtrl+F12.

In the popup, select the column of interest and do one of the following:

  • To sort the data by this column in the ascending order, pressShift+Alt+Up.

  • To sort the data in the descending order, pressShift+Alt+Down.

  • To cancel sorting by this column, pressCtrl+Shift+Alt+Backspace.

  • To hide the column (or show a hidden column), pressSpace. The names of hidden columns are shown struck through.

    TableResultPaneHideColumn

The shortcuts for sorting table data (Shift+Alt+Up, Shift+Alt+Down and Ctrl+Shift+Alt+Backspace) can be used in the Result pane without opening the structure view.

See also, To sort table data in a column, click the cell in the header row. , Hiding and showing columns and Restoring the initial table view.

Using the quick documentation view

The quick documentation view provides details about values in the selected cell or cells. For example, if a cell contains long text, you will see the whole text. If a cell contains an image, you will see a preview of the image. Also, you can see records that are referenced in the current record as well as the records that reference the current one.

Object

Documentation view

Long text

If a cell contains long text, you will see the whole text.

Quick documentation view for long texts

Image

If a cell contains an image, you will see a preview of the image.

Quick documentation view for images

Records

The quick documentation view for records displays records that are referenced in the current record and records that reference the current one.

Quick documentation view for an image

You can switch to the transposed view. In the transposed view, rows and columns are interchanged.

To switch to the transposed view, click Transposed View. For more information about the transposed view, see .

Transposed view for records

Transpose a table

You can rotate the table data from rows to columns and from columns to rows. In the transposed view, the rows and columns are interchanged.

To transpose a table, click the settings icon (The table settings icon) and select Transpose.

Inject a language for a column

You can assign a formal language (such as HTML, CSS, XML, RegExp, etc.) for the whole column. So, when you have a piece of code inside the cell that belongs to the column, you can use code generation, code completion, and other features IDE features.

To inject a language for the whole column, right-click the corresponding header cell, and select Edit As. In the list of supported languages, select the language that you want to inject.

Inject a language for a column

Selecting cells and ranges: using unobvious techniques

Adding cells with the same contents. Select a cell. Now, to add the nearest cell with the same contents to the selection, pressAlt+J. (When looking for the corresponding cell, PhpStorm moves down.) Each next press of Alt+J will add another cell to the selection.

To remove the cells from the selection one by one - starting from the last selected cell - useShift+Alt+J.

If a number of cells in the same row are initially selected, Alt+J and Shift+Alt+J work the same way.

Expanding a selection: cell - column - row - table. Select a cell. Now, to select all the cells in the current column, pressCtrl+W. The second press of Ctrl+W cancels the selection of the column and selects all the cells in the current row. Finally, the third press of Ctrl+W selects the whole table.

Ctrl+W works similarly if a number of cells or a range is initially selected.

Basic operations with cells

You can modify values in the table cells and, if appropriate, upload files.

Action

Shortcut

Description

Edit

F2

Edit a cell value. Alternatively, select a cell and start typing a new value. To confirm your changes, press Enter.

Edit Maximized

Shift+Enter

Expands a cell for editing. To confirm your changes, press Ctrl+Enter.

Add a new line

Ctrl+Enter

Adds a new line in the regular editing mode (F2).

Revert selected

Ctrl+Alt+Z

Restores the previous cell value.

Maximize

Ctrl+Shift+Alt+M

Expands the selected cell.

Add a new line in a maximized cell

Enter

Adds a new line in the maximized editing mode (Shift+Enter). To confirm your changes, press Ctrl+Enter.

Set the default value

Ctrl+Alt+D

Sets the current cell value to the default value.

Set the NULL value

Ctrl+Alt+N

Sets the current cell value to the NULL value.

Load file

Uploads a file into the field. Right-click a cell and select Load File.

Edit as

F2 or Shift+Enter

Edit a value in the cell as a fragment of SQL, HTML, XML, or any other supported language.

Edit a value in the cell as a fragment of a supported language

Value completion

Ctrl+Space

Opens the suggestion list. To invoke value completion, start editing the cell and press Ctrl+Space. The list contains values from the current column that match your input.

Adding cells with the same contents to the selection

Alt+J

Adds the nearest cell with the same contents to the selection. To remove a cell from the selection, press Shift+Alt+J.

Expand a selection from a cell to a table

Ctrl+W

Expands a selection from a cell to a table.

  • Press one time: the selection expands to a column.

  • Press two times: the selection switches from the column to a row.

  • Press three times: the selection expands to the whole table.

Compare cells

Ctrl+Shift+D

Compares the contents of two or three cells within one table. Select up to three cells and press Ctrl+Shift+D. Alternatively, right-click the selection and select Compare Cells.

Compare cells

Edit multiple cell values simultaneously

  1. Select a range of cells that you want to edit.

  2. Start typing a new value. The changes are applied to all the selected cells.

  3. To confirm the value, pressEnter. To cancel editing, pressEscape.

Add a row

  1. Click the Add New Row icon (The Add New Row icon) on the toolbar. Alternatively, right-click the table and select Add New Row from the context menu.

  2. PressAlt+Insert.

Delete a row

  1. Select the row or rows that you want to delete.

    Rows are selected by clicking the cells in the column where the row numbers are shown. To select more than one row, use mouse clicks in combination with the Ctrl key.

  2. Click the Delete Row icon (the Delete Row icon) on the toolbar. Alternatively, press Ctrl+Y or Delete.

Submit changes manually

By default, changes in tables are not submitted automatically. At first, you make changes in your local copy of the table, then you need to submit all changes to a database.

To submit changes to a database, click the Submit icon (The Submit icon), or pressCtrl+Enter.

Submit changes automatically

By default, changes are not submitted to a database unless you press the Submit icon (The Submit icon), or pressCtrl+Enter. You can enable the Submit changes immediately option to submit your changes automatically.

  1. In settings (Ctrl+Alt+S), navigate to Database | Data Views.

  2. Select Submit changes immediately.

  3. Click OK.

Submit changes by using database transactions

You can select to commit transactions automatically or manually. To change the commit mode, use the Tx drop-down menu on the toolbar.

Change the transaction level

If you submit a change to the database server and the commit mode is set to Auto, each change of values, rows, or columns is implicitly committed and cannot be rolled back.

If the commit mode is set to Manual, you can explicitly commit or roll back submitted changes by means of the Commit icon (The Commit icon) or the Rollback icon (The Rollback icon). Otherwise, select Commit (Ctrl+Shift+Alt+Enter) or Rollback commands from the context menu.

The Tx switch can also be used for selecting the isolation level for the transactions.

Revert changes

Before you submit the changes, you can revert them.

The scope of the revert command is defined by the current selection in a table: the command is applied only to the changes within the selection. So you can revert an individual change, a group of changes or all the changes. If nothing is currently selected, the revert command is applied to the whole table.

To revert non-submitted changes, select and right-click a cell or a number of cells. Select Revert Selected (Ctrl+Alt+Z).

Managing database transactions

You can select to commit transactions automatically or manually. To change the commit mode, use the Tx switch buttonTransactionControlDB on the toolbar.

TransactionControlDB

If the commit mode is set to Auto, each change of a value, or adding or deleting a row - when submitted to the database server - is implicitly committed and cannot be rolled back.

If the commit mode is set to Manual, the changes you have submitted to the server can be explicitly committed or rolled back by means of iconDBCommitTransaction or iconDBRollbackTransaction on the toolbar, or the Commit or the Rollback context menu command.

The Tx switch can also be used for selecting the isolation level for the transactions.

Compare tables

You can compare the current table with any other table that is open in a data editor or shown in the Database Console tool window.

  1. Select a table.

  2. Click the Compare with icon (The Compare with icon), and select another table or a result set.

  3. If needed, change the 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.

Export a table to a file

When you copy table data to the clipboard or save it in a file, the data is converted into one of the available output formats. As an output format, you can select SQL INSERT or UPDATE statements, TSV or CSV, an HTML table or JSON data.

Open a table or a result set, click the Dump Data icon (The Dump Data icon) and select To File.

Export a view to a file

Export a table to a clipboard

On the toolbar, click the Dump Data icon (The Dump Data icon) and select To Clipboard.

Copy and paste cells between tables

You can copy (Ctrl+C) and paste (Ctrl+V) selected cells and ranges of cells - within the same table or from one table to another one. When pasting, PhpStorm converts data types automatically if and as necessary.

Configure a data output format and options

You can configure how extracted data is converted into text using predefined output formats, customized formats, and scripts. To configure the output for extracted data, right-click any cell in the table and point to Data Extractor.

The table editor context menu

In this menu, you can select the output format (for example, as SQL INSERT statements, HTML table, or in CSV format) or a script that converts data into a specific format. The following additional options are also available:

Skip Computed Columns (SQL)
Enable to exclude columns with calculated values (affects SQL output formats).
Skip Generated Columns (SQL)
Enable to exclude columns with auto-increment values (affects SQL output formats).
Add Table Definition (SQL)
Enable to include the CREATE TABLE statement (affects SQL output formats).

Additionally, you can configure the following parameters:

  • Configure CSV Formats. Opens the CSV Formats dialog that you can use to manage your delimiter-separated values formats (for example, CSV or TSV).

  • Go to Scripts Directory. Opens a directory with the scripts that convert table data into various output formats.

Exporting the data to another table, schema or database

You can export the data to another table, schema or database:

  1. Do one of the following:
    • Click iconExportToDB on the toolbar.

    • Select Export to Database from the context menu.

  2. Select the target schema (a new table will be created) or table (the data will be added to the selected table).

  3. In the dialog that opens, specify the data mapping info and the settings for the target table.

Saving a LOB in a file

You can save a binary large object (BLOB or LOB) from a cell into a file.

  1. Right-click the cell that contains the LOB and select Save LOB.

  2. In the save dialog, specify the name and location of the file and click OK.

Update the table view

You need to update the table view if you want to synchronize the data that you see in the editor with the contents of the database. Or, when you want to apply the page size limit setting after its change.

To refresh the table view, consider the following actions:

  • Click the Synchronize icon (The Synchronize icon) on the toolbar.

  • Right-click the table and select Reload Page from the context menu.

  • Press Ctrl+F5.

View the query that generated the table

To see the query that was used to generate the table, click View Query on the toolbar. If necessary, you can select the query text and copy it to the clipboard (Ctrl+C).

To close the pane where the query is shown, press Escape.

Build a query plan

  1. Right-click an SQL statement, and select Explain plan.

  2. In the Output pane, click Plan.

  3. By default, you see the tree representation of the query. To see the query plan, click Show Visualization (the Show Visualization button), or press Ctrl+Shift+Alt+U.

Viewing SQL Query map
Last modified: 22 January 2019

See Also