Why I love IntelliJ's database window
Tags: java, intellij, beginners, database
Published: 2022-10-28 18:48:02

---
title: Why I love IntelliJ's database window
published: true
date: 2022-10-28 16:36:24 UTC
tags: java, intellij, beginner, database
canonical_url: 
---

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1661022982152/m0-kuWqpv.png)

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1661022989903/Dd7CThSce.png)

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1661022999215/fj0AO38k6.png)

Gives a preview of the affected row:

![affected-row](https://cdn.hashnode.com/res/hashnode/image/upload/v1661023043742/6o9hchdhH.png)

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](https://cdn.hashnode.com/res/hashnode/image/upload/v1666975509537/kIcd9Werh.png)
Quite helpful in my opinion! This also works for update statements:

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1666975492087/j17aB9Q5_.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](https://cdn.hashnode.com/res/hashnode/image/upload/v1661023063535/CHiZiSDjK.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!