# Schema comparison and migration

> **TL;DR**
> In the   Database   tool window , select two database objects and press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)).
>
>
>
> For the data comparison functionality, refer to the [Compare the data of database objects](compare-data.html) topic.

Procedure: Enable the Database Tools and SQL plugin

This functionality relies on the  Database Tools and SQL plugin, which  is bundled and enabled in IntelliJ IDEA   by default. If the relevant features are not available, make sure that you did not disable the plugin.

> **Note:**
> Database Tools and SQL functionality support is limited in IntelliJ IDEA without the Ultimate subscription.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.

In IntelliJ IDEA, you can compare two database objects of the same type. For example, you can compare two schemas, two tables, or two routines. Databases with objects can be hosted on different servers. IntelliJ IDEA shows you the differences in the structures of these two objects in the Migration dialog.

Migration is a process of transferring structure and changes from one object to another (for example, from one schema to another). In IntelliJ IDEA, these objects are called Origin and Target. The migration script is generated to make Target equal to Origin. But you can modify the script to satisfy your requirements.

![Compare the structure in Migration dialog](https://resources.jetbrains.com/help/img/idea/2026.2/db_schema_migration_dialog.png)

For changes, IntelliJ IDEA uses the following color coding.

| Color | Description |
| --- | --- |
| ![Items are new](https://resources.jetbrains.com/help/img/idea/2026.2/db_diff_items_added.png) | Objects added in Origin, which will be created in Target in case of a successful migration. |
| ![Items are different](https://resources.jetbrains.com/help/img/idea/2026.2/db_diff_items_modified.png) | Modified objects, which will be altered in Target. |
| ![Items to be deleted](https://resources.jetbrains.com/help/img/idea/2026.2/db_diff_items_to_be_deleted.png) | Objects deleted in Origin, which will be dropped in Target in case of a successful migration. |

See the description of the dialog controls in [the reference section](#controls_of_the_migration_dialog).

## Schema comparison

Procedure: Show differences between objects

1. In the   Database   tool window ,  select two objects of the same type. For example, two schemas.

2. Right-click the selection and select Compare Structure With. Alternatively, press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)).

![Differences between objects in the Migration dialog](https://resources.jetbrains.com/help/img/idea/2026.2/db_compare_two_schemas.png)

Procedure: Show differences between changes in a table form

1. In the Migration dialog, click an item in Origin or Target fields.

2. Click the Object Properties Diff tab.

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/db_differences_between_object_properties.mp4)

Procedure: Show differences between changes in DDL

1. In the Migration dialog, click an item in Origin or Target fields.

2. Click the DDL Diff tab.

![Differences between object properties](https://resources.jetbrains.com/help/img/idea/2026.2/db_differences_between_object_properties_in_ddl.png)

Procedure: Show identical items

* To display all items that are identical in Origin and Target objects, select the Show identical checkbox.

Enabled:

![The Show identical records option is enabled](https://resources.jetbrains.com/help/img/idea/2026.2/db_show_identical_records_on.png)

Disabled:

![The Show identical records is disabled](https://resources.jetbrains.com/help/img/idea/2026.2/db_show_identical_records_off.png)

## Schema migration

Procedure: Migrate changes between objects

1. In the   Database   tool window ,  select two objects of the same type. For example, two schemas.

2. Right-click the selection and select Compare Structure With in the context menu. Alternatively, press `Ctrl+D` (Windows), `⌘ D` (macOS), `⌘ D` (IntelliJ IDEA Classic (macOS)), `⌘ D` (macOS System Shortcuts), `Ctrl+D` (XWin), `Ctrl+D` (GNOME), `Ctrl+D` (KDE), `Ctrl+D` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `Ctrl+D` (NetBeans), `Ctrl+D` (Visual Studio), `⌘ D` (Visual Studio (macOS)), `Ctrl+D` (Eclipse), `⌘ D` (Eclipse (macOS)).

A set of statements that you can use for writing migration scripts is generated in the Script Preview tab.

3. In the Script Preview tab, verify that the migration scripts are correct.

4. Click Execute. Alternatively, click Open Query in Console to open all the scripts in a query console.

Procedure: Select changes to migrate

* To exclude a change, click the checkbox neat the change.

* To exclude all the changes, click the checkbox near the Target label.

* To include all the changes that were excluded, click the checkbox near the Target label.

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/db_select_changes_to_migrate.mp4)

## Controls of the Migration dialog

| Icon | Tooltip and shortcut | Description |
| --- | --- | --- |
| ![Expand All](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.expandAll.svg) | Expand All | Expands all the collapsed nodes. |
| ![Collapse All](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.collapseAll.svg) | Collapse All | Collapses all the expanded nodes. |
| ![Swap](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.actions.swapPanels.svg) | Swap | Swap the Origin and Target panels. |
| ![Options](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.settings.svg) | Options |      * Qualify objects with schema names: Sets when to qualify database objects with schema names. * Never: do not add a schema name. * Always: add a schema name to all the object names. * Auto: omit a schema name when all the objects belong to one schema or the schema is current. In most cases, the current schema is the schema that a user chose to log in. This option affects the generated code and does not affect the code received directly from the server.    * Place constraints: Sets where to place contraints.    * Allow object recreation: Recreate object if alteration is not possible.    * Use surrogate (auto-generated) names: Use the names that were omitted by the author and generated automatically on the server side.    * Ignore modification of the identifier case: Ignore identifier case modification.    * Generate disabling clauses or statements: Generate code for disabling elements that are currently disabled.    * Ignore owner: Ignore the object owner in the generated script.    * Skip grants: Do not generate grant code for privileges.    * Show grants in user definition: Renerate grants on all accessible objects.    * Ignore order: ignore column order.    * Regenerate database-provided code: Regenerate property definitions that are provided as a part of source code by the database.    * Reformat generated code: Reformat generated code using the current code style profile. This option affects the generated code only and does not affect the code received directly from the server.    * Ignore extension members: Ignore the objects originated from extensions.    * Ignore Implicit Objects: Ignore objects that are generated automatically. For example, indexes for foreign keys, `DEFAULT CONSTRAINT` for a column default in Microsoft SQL Server.    * Ignore Source Code: Ignore the body in functions or procedures. Objects are matched according to their kind and identity (for example, a function signature). Two functions are considered equal if their kind and identity are equal. Then the Diff Viewer takes into account this option – whether to ignore the function body or not.    |
| ![Selected](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.com.intellij.ide.ui.laf.icons.intellij.checkBoxSelectedDisabled.svg) | Include change | Apply the selected change. |
|  | Show identical | Show all items that are identical. |

### Controls of DDL Diff

| Item | Tooltip and Shortcut | Description |
| --- | --- | --- |
| ![the Previous Difference button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.up.svg)/![the Next Difference button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.down.svg) | Previous Difference / Next Difference     `Shift+F7` (Windows), `⇧ F7` (macOS), `⇧ F7` (IntelliJ IDEA Classic (macOS)), `⌘ [` (macOS System Shortcuts), `Shift+F7` (XWin), `Shift+F7` (GNOME), `Shift+F7` (KDE), `Shift+F7` (Emacs), `Shift+F7` (Sublime Text), `⇧ F7` (Sublime Text (macOS)), `Shift+F7` (NetBeans), `Shift+F7` (Visual Studio), `⇧ F7` (Visual Studio (macOS)), `Shift+F7` (Eclipse), `⇧ F7` (Eclipse (macOS)) / `F7` (Windows), `F7` (macOS), `F7` (IntelliJ IDEA Classic (macOS)), `⌘ ]` (macOS System Shortcuts), `F7` (XWin), `F7` (GNOME), `F7` (KDE), `F7` (Emacs), `F7` (Sublime Text), `F7` (Sublime Text (macOS)), `F7` (NetBeans), `F7` (Visual Studio), `F7` (Visual Studio (macOS)), `Ctrl+F7` (Eclipse), `⌃ F7` (Eclipse (macOS))   |    Jump to the next or previous difference.     |
|  ![the Jump to Source button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.edit.svg)  |    Jump to Source     `F4` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS))    |    Open a definition of the selected object in the active pane in the editor. The caret is placed in the same position as in the Diff Viewer.    |
|  |  Side-by-side viewer  |     Select a viewer mode: Side-by-side viewer or Unified viewer. The side-by-side mode has two panels, and the unified mode has one panel.     |
|  | Whitespaces |    Define how the Diff Viewer should treat whitespaces.        * None: white spaces are important, and all the differences are highlighted. This option is selected by default.    * Trim whitespaces: trim whitespaces if they appear in the end and at the beginning of a line (`("\t", " ")`). * If two lines differ in trailing whitespaces only, these lines are considered equal. * If two lines are different, trailing whitespaces are not highlighted in the [By word](#highlight) mode.    * Ignore whitespaces: white spaces are not important, regardless of their location in the source code.    * Ignore whitespaces and empty lines: ignores whitespaces and empty lines. The following entities are ignored: * all whitespaces (as in the Ignore whitespaces option) * all added or removed lines that consist of whitespaces only * all the changes that split or join lines without changes to non-whitespace parts. For example, differences between `a b c` and `a \n b c` are not highlighted in this mode.    |
|  | Highlighting mode |    Select the way differences are highlighted.      The available options are:       * Words: modified words are highlighted    * Lines: modified lines are highlighted    * Split changes: if this option is selected, large changes are split into smaller changes. For example, `A \n B` and `A X \n B X` are treated as two changes instead of one.    * Highlight Symbols: modified symbols are highlighted    * None: if this option is selected, the differences are not highlighted at all. Use the None option when you work with objects that were significantly modified. In such cases, highlighting might introduce additional difficulties during a review.    |
| ![Synchronize Scrolling](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.actions.synchronizeScrolling.svg) | Synchronize Scrolling | Synchronize scrolling in the left and right panes. |
|  ![the Settings button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.settings.svg) | Settings |    Select options that you want to ignore during the comparison.       * Show Whitespaces: displays whitespaces as the dots in the Diff Viewer.    * Show Line Numbers: displays line numbers in the Diff Viewer.    * Show Indent Guides: displays vertical lines in the Diff Viewer to indicate positions of indents.    * Soft-Wrap: wraps the lines of code, when the dialog is resized.    * Highlighting Level: allows you to select the [highlighting level](disabling-and-enabling-inspections.html#change-highlighting-level-for-file) in the Diff Viewer.    * Annotate: [annotates](investigate-changes.html#annotate_blame) the changes. > **Tip:** > This option is available only for the files under version control.    |
|  ![the Help icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.help.svg)  |    Help   `F1` (Windows), `⌘ ⇧ F1` (macOS), `F1` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ F1` (macOS System Shortcuts), `F1` (XWin), `F1` (GNOME), `F1` (KDE), `F1` (Emacs), `F1` (Sublime Text), `⌘ ⇧ F1` (Sublime Text (macOS)), `F1` (NetBeans), `F1` (Visual Studio), `F1` (Visual Studio (macOS)), `F1` (Eclipse), `⌘ ⇧ F1` (Eclipse (macOS))  | Open a browser and show the corresponding help page. |

