Why I love IntelliJ's database window

Photo by Jan Antonin Kolar on Unsplash

Why I love IntelliJ's database window

Tobias Haindl's photo
Tobias Haindl
·Oct 28, 2022·

2 min read

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 effortless 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!
Let’s 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!

Did you find this article valuable?

Support codeblend by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
 
Share this