DataGrip tips and tricks (part 3)
3 min read

DataGrip tips and tricks (part 3)

DataGrip tips and tricks (part 3)

You can read part 1 here and part 2 here!

Hide tables

DataGrip is an excellent tool for indexing all the tables in your database and quickly finding every object. However, in some cases, you might need to exclude a table from the code autocompletion and the database tree view. If you need that, go to your Data Source settings → Schemas and type the desired exclusion pattern in the Object filter field. For example, if you want to stop seeing all the tables that start with 'OLD_' type: table:-OLD_.*  (I hope your database doesn't have so much garbage :D).

DataGrip - Hide tables

Expand column list

In a select sentence, you can avoid typing every column name. Instead, press Alt+Enter from the wildcard and select 'Expand column list', and you will obtain all the tables' columns. If two columns have the same name, DataGrip will qualify them with their respective aliases.

DataGrip - Expand column list

Explain Plan visualization

We will discuss the usefulness of analyzing the execution plan in a separate post. Still, if you are already familiar with the 'Explain plan' option, you may not know that DataGrip also allows you to obtain a diagram that visualizes the query plan.

Once you click on 'Explain Plan' from the context menu of your query, click on the 'Show visualization' icon (at the top left of the results section) or press Ctrl+Alt+Shift+U. The resulting diagram is helpful to understand the execution steps of your query.

Copy a table or a results set to a database

You can quickly create a copy of an existing table by dragging it from the database tree view to the top 'tables' folder. An import window will open to confirm the table's name and its definition.

You can also export only one result set to another database: click from the results section on 'Copy to Database ...' and select the target schema.

DataGrip - Copy table

Local History

This is one of my favorite DataGrip features. Local History continually tracks all the changes you make in the editor and allows you to review them and restore previous versions.

Right-click anywhere in the editor and, from the context menu, select Local History -> Show history. The dialog that opens shows the list of all automatically saved versions and, on the right side, a diff viewer shows the differences between the current state of your file and the old state of the selected version.

You can find more info about Local History options here.

Bonus: Quickly name the results tab

When you have different results, you can rename each result tab with the 'Rename tab' option to find it more easily.

You can solve this need in advance: write a commented text in the line before your query, and the result will automatically have that text in its name.

DataGrip - Name tab from comment