To sort the column data, click the column name. By default, a new
ORDER BY query is sent to the database each time you click a column name. In the Services tool window (Output tab), you can see all the corresponding sorting operations.
You can also sort the data on the client side. To do that, click the Show Options Menu button () and deselect the Sort via ORDER BY option.
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.
Indicates that the data is not sorted in this column. The initial state of the sorting marker.
The data is sorted in the ascending order.
The data is sorted in the descending 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.
To change the default option for stacked sorting, open settings by pressing Control+Alt+S and navigate to Add columns to sorting option.. Change the value for the
Also, you can use the ORDER BY filter and sort data in a table by writing a query in the ORDER BY field.
Sort table data with a query
In the ORDER BY field, type your query. The query syntax is the same as in the
ORDER BYclause but without the keyword.
To reset the filter, click the clear icon (), or delete the contents of the row filter field and press Enter.
To open the filter history, click the arrow icon near the ORDER BY keyword.
Set default sorting by a primary key
For the tables that have a numeric primary key, DataGrip can sort the data by that key. IDE will send a new
ORDER BY query to the database each time you view the table data in data editor.
Press Control+Alt+S to open the IDE settings and then select.
Under Data Sorting, select Sort tables by numeric primary key.
Select Ascending or Descending to set the sorting order.