IntelliJ IDEA 14.1.0 Help

Working with the Database tool window

The Database tool window provides access to functions for working with databases and DDL data sources. It lets you view and modify data structures in your databases, and perform other associated tasks.

See also, Database Tool Window.

Opening the Database tool window

Do one of the following:

  • Select View | Tool Windows | Database.
  • Point to show_tool_window_bars or show_hide_tool_window_bars in lower-left corner of the workspace, and then click Database.
  • Click Database on the right-hand tool window bar (if the tool window bars are currently shown).

Adjusting the view

You can adjust the view in the tool window by turning the corresponding view options on and off. To access those options, click viewMode on the title bar.

For more information, see View options.

Creating a data source

To start creating a data source, you can use the New command when the Database tool window is active. Do one of the following:

  • Select File | New | Data Source or File | New | DDL Data Source.
  • Click add on the toolbar and select Data Source or DDL Data Source.
  • In the context menu, select New and then select Data Source or DDL Data Source.
  • Press Alt+Insert and select Data Source or DDL Data Source.

Alternatively, you can open the Data Sources and Drivers dialog (e.g. iconManageDataSources) and use the Add command there: Add from the context menu, add on the toolbar, or Alt+Insert.

For more information, see Managing Data Sources.

Creating a table, a column, an index, or a primary or foreign key

  1. Depending on what you are going to create:
    • To create a table, select a schema, table or column within the target DB data source.
    • To create a column, select the target table or a column within that table.
    • To create an index, or a primary or foreign key, select the column or columns for which you want to create an index, or a primary or foreign key constraint.
  2. Carry out the New command and select the item to be created. E.g. for a table, do one of the following:
    • Select File | New | Table.
    • Click add and select Table.
    • In the context menu, select New | Table.
    • Press Alt+Insert and select Table.
  3. In the dialog that opens:
    • The upper part, if appropriate, provides a GUI for specifying the item name and other info.
    • SQL Preview pane lets you view and edit the statement which is run when you click OK.
    • openQueryInConsoleIcon copies the statement into the database console and closes the dialog.

Viewing basic info about an item

You can view basic info for about an item in the quick documentation view. For a table, for example, the first ten rows and the table definition (the CREATE TABLE statement) are shown.

To open the quick documentation view, select the item of interest and do one of the following:

  • Select View | Quick Documentation.
  • Press Ctrl+Q.

Renaming a table or column

  1. Select the table or column to be renamed.
  2. Do one of the following:
    • Select Refactor | Rename.
    • Select Rename from the context menu.
    • Press Shift+F6.
  3. In the dialog that opens, specify the new name for the table or column and click Refactor.

Modifying a column definition

  1. Select the column whose definition you want to change.
  2. Do one of the following:
    • Select Modify Column from the context menu.
    • Press Ctrl+F6.
  3. In the dialog that opens:
    • The upper part provides a GUI for specifying the column definition.
    • SQL Preview pane lets you view and edit the statements which are run when you click Refactor.
    • openQueryInConsoleIcon copies the statements into the database console and closes the dialog.

Removing items

To remove items such as data sources, tables, columns and indexes, use the Delete command (Edit | Delete, Delete from the context menu, or Delete on the keyboard).

To remove primary and foreign key constraints, use the Drop Associated | Primary Key or the Drop Associated | Foreign Key context menu command.

Opening a database console

  1. Select the DB data source of interest or any node within it.
  2. Do one of the following:
    • Click runJdbcConsole on the toolbar.
    • Select Console from the context menu.
    • Press Ctrl+Shift+F10.

For more information, see Working with Database Consoles.

Opening the table editor

  1. Select the table of interest.
  2. Do one of the following:
    • Click DataTables on the toolbar.
    • Select Table Editor from the context menu.
    • Press F4.

For more information, see Working with the Table Editor.

Generating DDL definitions for data sources, tables and columns

  1. Select the data source, table or column of interest.
  2. Do one of the following:
    • Click DDLCopy on the toolbar.
    • Select Copy DDL from the context menu.
    • Press Ctrl+Shift+C.

    The definitions are generated on the clipboard and you can paste them into a database console or an SQL file.

Comparing DDL definitions for data sources and tables

  1. Select two data sources or tables.
  2. Do one of the following:
    • Click showAllPAthsAffected on the toolbar.
    • Select Compare from the context menu.
    • Press Ctrl+D.

Saving table data in a file

  1. Right-click the table of interest.
  2. Point to Save To File and select the output format (e.g. CSV).
  3. In the dialog that opens, specify the file location and name.

Viewing diagrams

To open a diagram for a data source, schema or table, select the item of interest and do one of the following:

  • Press Ctrl+Shift+Alt+U or Ctrl+Alt+U.
  • Click icon_UML on the toolbar and select Show Visualisation or Show Visualisation Popup.
  • In the context menu, select Diagrams, and then select Show Visualisation or Show Visualisation Popup.

Closing database connections

IntelliJ IDEA connects to databases automatically, when needed. (The names of the data sources with open database connections are shown in the Database tool window in bold.)

To close unnecessary database connections, select the corresponding data sources and do one of the following:

  • Click stop on the toolbar.
  • Select Disconnect from the context menu.
  • Press Ctrl+F2.
Last modified: 14 July 2015