Review DataGrip's SQL Preview Before Running Schema Changes
Inspect DataGrip's SQL Preview before executing schema changes to catch DDL, locking, and migration-format issues early.
21 Apr 2026, 19:45 UTC

The problem is the DDL you never saw
You open DataGrip to add a column to a staging table. In the Modify Table dialog, you choose a name and type, click Execute, and the change runs. Later, your deployment pipeline rejects the change because the generated ALTER TABLE does not match your team's Flyway format, or a production table stays locked longer than expected. The problem is usually not DataGrip itself. It is the DDL you never inspected between the dialog and the database.
DataGrip can generate a change script for GUI-driven table modifications and show it in an SQL Preview pane before anything executes. You can read that preview, edit it, save it as a migration file, or run it directly. Treating that pane as a required review step gives you control over schema changes instead of discovering problems after they are applied.
What the SQL Preview shows
When you modify a table through the GUI—adding or dropping columns, changing types, or renaming objects—DataGrip validates the syntax against your connected data source dialect and renders the corresponding DDL in the SQL Preview pane. The preview covers common operations across PostgreSQL, MySQL, SQL Server, and Oracle. On databases that support transactional schema changes, such as PostgreSQL, DataGrip wraps the previewed DDL in a transaction. That does not mean every database is safe to experiment on; transactional support depends on the target engine and, in some cases, the storage engine.
Worked example: add a column in PostgreSQL
- Open the Database tool window, expand your data source, and right-click a table—for example,
public.users. - Choose Modify Table. In the Columns tab, add a column named
email_verifiedwith typebooleanand a default offalse. - Locate the SQL Preview pane. For PostgreSQL, expect a statement similar to:
ALTER TABLE public.users ADD COLUMN email_verified boolean DEFAULT false;- Read the statement. If it looks correct, you can click Execute. If you want to keep it for version control, save it as a migration file instead, such as
V3__add_email_verified.sql, and review it with your team before committing. - Required permission: you generally need ALTER privileges on the table or schema, depending on the database. Running without the right privilege produces an authorization error at execution time, not in the preview.
- Risk: clicking Execute sends the DDL immediately. On databases without transactional DDL, a failed script can leave partial schema changes behind.
Where the preview can surprise you
- Dialect gaps: complex changes may be split into multiple statements or omit database-specific options. Preview accuracy varies by dialect.
- Migration mismatch: generated SQL may not match Flyway or Liquibase exactly. Review formatting, delimiters, and comments before committing to version control.
- Version differences: dialogs and preview behavior differ between DataGrip releases. Verify against your installed version.
Verification checklist
- Test the previewed script on a disposable schema or copy of production data first.
- After executing, refresh the database tree and confirm the column appears in the table definition. In PostgreSQL, you can query
information_schema.columnsto verify. - If your database supports transactional DDL, you can test inside a transaction and roll back, but remember that some DDL statements implicitly commit in certain engines.
- Compare the saved file against your team's migration template before opening a pull request.
Make the preview a checkpoint, not an option
The SQL Preview pane is not a guarantee that the change is safe; it is a checkpoint. Spend the thirty seconds reading the generated ALTER TABLE before you execute it, and you will catch syntax, locking, and migration-format issues before they reach production.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.