In this article I want to share some of my favorite features of IntelliJ's database window/console.
Let's jump right in!
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:
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
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:
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.
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!
Gives a preview of the affected row:
In my opinion this makes removing data from your production database far more comfortable 🙂
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.
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!
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!