Database diagrams
In the Database tool window, right-click a database object and select Diagrams | Show Diagram
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
The Database Tools and SQL plugin is not available in IntelliJ IDEA Community Edition.
Press CtrlAlt0S to open settings and then select Plugins.
Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
This functionality relies on the Diagrams 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.
Press CtrlAlt0S to open settings and then select Plugins.
Open the Installed tab, find the Diagrams plugin, and select the checkbox next to the plugin name.
Database diagrams graphically show the structure of the database and relations between database objects. You can generate a diagram for a data source, a schema, or a table. To create relations between database objects, consider using primary and foreign keys.
You can save the generated diagrams in two formats: UML and PNG. The UML format is an internal format developed specifically for IntelliJ IDEA. It is not supported by other products. If you want to share the created diagram, consider using PNG.
Also, you can build execution plans. An execution plan is a set of steps that were used to access data in a database. For more information about creating an execution plan, refer to Visualize a query plan.
In the Database tool window (View | Tool Windows | Database) , right-click a database object and select Diagrams | Show Diagram.
To pan and zoom the diagram, use your touchpad, scroll bars or the mouse wheel for vertical scrolling and Shift + mouse wheel for horizontal scrolling. You can also use Shift + mouse wheel for zooming.
To use the magnifier tool, keep the Alt key pressed and hover over the desired areas of the diagram. Use the mouse wheel to extra zoom the diagram area within the magnifier tool.
Generate a diagram. For more information about generating a diagram, refer to Generate a diagram for a database object.
Click the Comments button ().
In the Database tool window (View | Tool Windows | Database) , right-click an object and select Tools | Set Color.
Select a color and click OK. Refresh the diagram to apply the color by clicking the Refresh button ().
In IntelliJ IDEA, you can export a diagram in various formats to a file, to clipboard, and open it in a web editor. You can also print a diagram and save it as an image. To do that, use the corresponding actions in the context menu of your diagram. For more information about the database diagram context menu, refer to Context menu.
To export your diagram to a third-party editor in web browser, right-click the diagram, navigate to Export Diagram | Open in Web Editor, and select the editor.
Alternatively, click the Export Diagram button () on the diagram toolbar, and select the editor in the corresponding submenu.
The supported editors are as follows:
To copy your diagram to clipboard, right-click the diagram, navigate to Export Diagram | Copy to Clipboard, and select the format.
Alternatively, click the Export Diagram button () on the diagram toolbar, and select the format in the corresponding submenu.
The supported formats are as follows:
Mermaid
classDiagram
{...}PlantUML
@startuml
{...}Graphviz DOT
digraph "sakila" {
{...}Graphviz DOT with Positions
digraph "sakila" {
{...}
To export your diagram to a file, right-click the diagram, navigate to Export Diagram | Export to File, and select the format.
Alternatively, click the Export Diagram button () on the diagram toolbar, and select the format in the corresponding submenu.
The supported formats are as follows:
YEd .graphml
JGraph .drawio
Graphviz .dot
Graphviz .dot with Positions
Mermaid .md
PlantUML
IDEA .uml: The UML format
is an internal format supported only by IntelliJ IDEA. To open the saved diagram, drag the UML file to the editor.
To export your diagram as an image in PNG format, right-click the diagram and select Export Diagram | Export to Image.
Alternatively, click the Export Diagram button () on the diagram toolbar, and select Export to Image.
Possible icon combinations for columns in diagrams:
Icon | Foreign key | Primary key | Indexed | NOT NULL |
---|---|---|---|---|
To configure the default visibility settings and layout for diagrams, Open settings by pressing CtrlAlt0S and navigate to Tools | Diagrams. .
For more information about database diagrams configuration settings, refer to the Diagrams reference topic.
For more information about database diagrams toolbar and context menu, refer to the Diagram toolbar and context menu reference topic.
Thanks for your feedback!