DEV Community 👩‍💻👨‍💻

Tobias Haindl
Tobias Haindl

Posted on • Originally published at codeblend.dev on

Why I love IntelliJ's database window

In this article I want to share some of my favorite features of IntelliJ's database window/console.

Let's jump right in!

Find usage of tables

One of my most used shortcuts is Find usage but it took me quite some time to figure out that this also works with database objects like tables:

usage

This makes refactoring your database easier since you can analyze the dependencies between your database objects and your source code quite easily with the help of Find usage

Multiple consoles

In IntelliJ, it is possible to have multiple database consoles for a single data source.

All open consoles can be found under Scratches and Consoles in the side navigation:

consoles

Furthermore, those console can be renamed like all the other files in your project!

For me this is especially helpful when I have to switch between different issues or tasks. With the help of multiple consoles I can keep all the queries needed for analyzing an issue together in one console and even give the console a telling name, so I can find those queries faster later on.

Safety features

Preview delete

Like in the normal source code editor ALT + ENTER is your best friend in the database console as well. With it, you can safely preview a delete query!

preview-delete

Gives a preview of the affected row:

affected-row

In my opinion this makes removing data from your production database far more comfortable 🙂

Warnings

Tired of dropping all your data due to a missing where condition in your delete statement? IntelliJ issues a warning for unsafe statement and requires extra confirmation before executing such statements.

image.png
Quite helpful in my opinion! This also works for update statements:

image.png

Auto-expand column names

Last but not least, auto expansion!

Lets say you want to select nearly all of your columns but do not want to type all column names manually.

In my opinion the easiest way to achieve this is by using the expand column list feature. Simply write: SELECT * FROM <your_table> highlight the asterisk character and press ALT + ENTER. This will give you all the column names, afterwards you can delete any unwanted column!

expand-column-list.gif

Wrap up

That's all from my side for now.

What do you think about the mentioned features?

Did I miss a feature you love?

Let me know in the comments!

Top comments (5)

Collapse
 
cloutierjo profile image
cloutierjo

Auto complete on join is also very useful.

The only thing I'm really missing is a good way to navigate the data without actually doing queries. I know there is a view mode that can be filtered then starting from a row you can navigate to foreign table (or see in an inspect pop-up) but it's kind of too cumbersome of you want to compare multiple foreign row or go more than one level.

Collapse
 
tobhai profile image
Tobias Haindl

That is very true!

Collapse
 
hcamacho4200 profile image
Henry Camacho

I love the database tab but I have issues trying to get my coworkers to use it

Collapse
 
datagrip profile image
JetBrains DataGrip

You don't need to select the wildcard before expanding :)

Collapse
 
tobhai profile image
Tobias Haindl

Good to know, thanks!

18 Useful Github Repositories Every Developer Should Bookmark

>> Check out this classic DEV post <<