From Code to Data: Using IntelliJ IDEA’s Database Tool Window to Cut Your Workflow Down to Zero
Stop hopping between IDE and database client. IntelliJ’s Database Tool Window lets you connect, query, edit, and migrate databases right in the editor. Discover how to set it up, run a real query against PostgreSQL, and weigh the pros and cons before you commit.
11 Jun 2026, 03:53 UTC

Why the Database Tool Window Matters
When you’re writing Java, Kotlin, or any JVM language, you’ll inevitably touch a database. The typical workflow is: edit a schema file, run a migration tool, open a separate SQL client, write a query, copy‑paste results back into the IDE. That split keeps you from seeing the full picture and introduces friction.
IntelliJ IDEA ships with a Database Tool Window that unifies these steps. From a single pane you can:
- Define JDBC connections and share them across projects
- Browse schemas, tables, and indexes with a tree view
- Run ad‑hoc queries with syntax highlighting and auto‑completion
- Edit data rows and commit changes directly
- Export, import, and run migration scripts
Below is a concrete example that shows how to connect to PostgreSQL, execute a query, and edit data, followed by a discussion of trade‑offs and next steps.
Step 1: Add a Data Source
Open the IDE, then View → Tool Windows → Database. Click the + icon and choose Data Source → PostgreSQL (the exact menu path may vary by version).
IDEA 2026.2 – Database Tool Window
-----------------------------------
1. Click + → Data Source → PostgreSQL
2. In the dialog, enter:
• Host: localhost
• Port: 5432
• Database: my_app
• User: app_user
• Password: (use the keyring icon to store securely)
3. Click Test Connection
– If the driver is missing, IDEA will prompt to download it.
4. Click OK
All credentials are stored in .idea/dataSources.xml and are encrypted by default. For cross‑project sharing, export the data source via File → Export Settings → Data Sources and import it into other projects.
Step 2: Run an Ad‑Hoc Query
With the data source selected, click the Console tab. IDEA opens a SQL console that supports:
- Syntax highlighting and linting
- Code completion for tables, columns, and functions
- Refactoring support (e.g., rename column)
Type a simple query and execute it:
SELECT 1 AS result;
Press Ctrl+Enter (or click the play icon). The result appears in the Result pane.
To test data editing, run:
SELECT * FROM users ORDER BY id LIMIT 5;
In the result grid, double‑click a cell, modify its value, and press Ctrl+Enter to commit. IDEA will send an UPDATE statement under the hood.
Step 3: Export and Migrate Data
Right‑click a table or data source and choose Dump Data to File. You can export CSV or SQL INSERT scripts. For migrations, integrate Flyway or Liquibase by adding a flyway.conf or liquibase.xml in your project and run the migration from the console:
# Flyway example
flyway -url=jdbc:postgresql://localhost:5432/my_app -user=app_user -password=secret migrate
IDEA can also run external migration tools via the Run/Debug Configurations dialog.
Trade‑Offs and Limitations
- Driver Dependency: You must have the JDBC driver on the classpath. IDEA will prompt to download it, but large drivers (e.g., Oracle) can increase startup time.
- Large Result Sets: Rendering millions of rows freezes the UI. Use
LIMITor pagination in your query to mitigate. - Advanced Features: Full‑text search tuning, database profiling, or complex replication settings are not exposed in the UI. Use external tools for those tasks.
- Credential Management: While IDEA encrypts passwords, they are still stored in project files. Consider external password managers or environment variables for high‑security environments.
Practical Verification Checklist
- Confirm the JDBC driver is present:
File → Settings → Plugins → Database Drivers. - Run
SELECT 1;and verify the result set appears. - Edit a row and commit; run a
SELECTagain to see the change persisted. - Export a table to CSV and open it in a spreadsheet to ensure data integrity.
- Check memory usage when running a query that returns >10,000 rows; if the IDE stalls, add a
LIMITclause.
Actionable Next Steps
- Enable
Show SQL in consoleunderSettings → Database → Generalto audit queries. - Configure
Data Source → Advanced → Use custom schemato limit the scope of browsing. - Set up
Data Source → Migrationto run Flyway scripts automatically on project startup. - Use the
DataGripplugin for advanced query profiling if you need deeper insights.
By consolidating database operations into IntelliJ IDEA, you reduce context switching, keep your code and data in sync, and accelerate feedback loops. Try it out on a small project today and see how much smoother your development cycle becomes.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.