CLion 2024.3 Help

Database tool window

Enable the Database Tools and SQL plugin

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

  1. Press Ctrl+Alt+S 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.

Overview

In the Database tool window ( View | Tool Windows | Database) , you can work with databases and DDL data sources. You can view and modify data structures in your databases and perform other associated tasks.

The available data sources are shown as a tree of data sources, schemas, tables, and so on.

the Database window

If no data sources are currently defined, use the New command Alt+Insert to create a data source and connect to a database. For more information about data sources, refer to the Data sources topic.

Once CLion is connected to a database, Database tool window will display the introspected database objects. For more information about the objects viewing options, refer to the View Options chapter. For more information about working with database objects in CLion, refer to the Database objects section.

Most of the functions in this window are accessed by using the toolbar icons or context menu commands. Many of the commands have keyboard shortcuts. If the toolbar is hidden, the Refresh and Open Query Console commands can be access by using the header buttons (the Refresh icon and the Jump to Query Console icon respectively).

Reference info

Toolbar

You can right-click the window header and use the context menu to configure its viewing mode, associate the window with a different tool window bar, or resize and hide the window.

You can also use the toolbar buttons:

Item

Shortcut

Description

Scroll from Editor

Automatically sets the focus on the object name in the Database tool window when the editor area is in focus.

Expand All

Ctrl+NumPad +

Expand all nodes in the current view.

Collapse all

Ctrl+NumPad -

Collapse all expanded nodes in the current view.

Hide tool window

Shift+Escape

Hide the tool window .

To hide all the tool windows, press Ctrl+Shift+F12.

Context menu

Item

Description

Autoscroll from Editor

Makes the database object, that is opened in the editor, automatically selected in the Database tool window. Disables the Scroll from Editor Scroll from Editor setting.

the Speed Search icon Speed search

Opens the input field of the Speed Search in tool windows feature.

Show Toolbar

Display the toolbar in the Database tool window.

View Mode

This option lets you control general appearance and behavior of the tool window. For full information, refer to Viewing modes.

Move to

To associate the tool window with a different tool window bar, select this command, and then select the destination tool window bar (Top, Left, Bottom or Right). For full information, refer to the Move tool windows chapter.

Resize

To resize the tool window by moving one of its borders, select this command, and then select the necessary Stretch to option.

Note that this command is not available for the floating mode.

Remove from Sidebar

This command hides the tool window, removes the associated tool window button from the tool window bar, and removes the tool window from the quick access menu (tb shown or tb hidden).

To open the tool window again (and restore the associated features), use the main menu: View | Tool Windows | <Window Name> or press Alt+1.

Help

This command opens the description of the Project tool window in the CLion online help.

Toolbar controls

Database tool window toolbar

Icon

Command

Shortcut

Description

Available for

the New icon

New

Alt+Insert

Create a new data source, role, database, schema, query console, table, column, index, or a primary or a foreign key. The list of options depends on which element is currently selected.

Data sources and their elements. If a DDL data source is selected, you can only choose to create another data source.

the Data Source Properties icon

Data Source Properties

Open the Data Sources and Drivers dialog to manage your data sources and their settings.

All node types

the Refresh icon

Refresh

Ctrl+F5

Update the view of the selected element (that is to synchronize the view of the element with its actual state in the database).

See also, Data Sources and Drivers dialog.

Data sources and their elements.

the Deactivate icon

Deactivate Ctrl+F2

Ctrl+F2

Close the database connection for the selected data source or data sources. (The data sources with connected sessions are indicated with a green dot in the corner of their icon.)

Data sources with active connections and their elements

the Jump to Query Console icon

Jump to Query Console

Ctrl+Shift+F10

Open the list of query consoles for the selected data source.

Data sources and their elements (tables and table columns)

the Edit Data icon

Edit Data

F4

Open a table view of the object in the data editor. This option works for tables, views, and materialized views.

Corresponding elements in data sources.

DDL

Go to DDL

Ctrl+B

Open the DDL script of the selected object.

For example, if you press this shortcut on a table's name in the SELECT statement, you will see the DDL of this table (the CREATE TABLE statement).

Go to Declaration

Corresponding elements in data sources.

the Compare Structure icon

Compare Structure

Ctrl+D

Compare the structure of two database objects in the Migration dialog.

Two selected database objects of the same kind.

View Options

Open the list of database object tree viewing options, including the item filter. For more information about the options, refer to the View Options chapter.

All items.

View Options

Database tool window Options menu items

Context menu

Context-menu actions appear when you right-click an object in the Database tool window.

Command

Shortcut

Description

Available for

Properties

Open the Data Sources and Drivers dialog to manage your data sources and their settings.

Data source and DDL data source nodes.

New

Alt+Insert

Create a new data source, role, database, schema, query console, table, column, index, a primary, or a foreign key. The list of options depends on which element is currently selected.

Data sources and their elements. If a DDL data source is selected, you can only choose to create another data source.

Rename

Shift+F6

Rename the selected item. Specify the new name in the dialog that opens.

Data sources and their elements.

Copy/Paste | Copy Reference

Ctrl+Alt+Shift+C

Copy the fully qualified name of the selected item to the clipboard.

Data sources and their elements.

Copy/Paste | Duplicate

Ctrl+D

Create a copy of the selected data source. Specify the properties of the data source in the Data Sources and Drivers dialog that opens.

Data source and DDL data source nodes.

Edit Data

F4

Open a table view of the object in the data editor. This option works for tables, views, and materialized views.

Corresponding elements in data sources.

Move to Folder

F6

Move the selected data source to a folder. If no folders exist yet, create the first one in the Move to Folder popup that appears.

For more information about grouping data sources, refer to Group data sources in folders.

Data source and DDL data source nodes.

Refresh

Ctrl+F5

Update the view of the selected element (that is to synchronize the view of the element with its actual state in the database).

See also, Data Sources and Drivers dialog.

Data sources and their elements.

Deactivate Ctrl+F2

Ctrl+F2

Close the database connection for the selected data source or data sources. (The data sources with connected sessions are indicated with a green dot in the corner of their icon.)

Data sources with active connections and their elements

Drop

or

Remove Data Source

Delete

Remove the selected item.

Data sources and their elements.

Quick Documentation

Ctrl+Q

View basic information about the selected element.

To close the documentation popup, press Escape.

Data sources and their elements.

Navigation | Go to DDL

Ctrl+B

Open the DDL script of the selected object.

For example, if you press this shortcut on a table's name in the SELECT statement, you will see the DDL of this table (the CREATE TABLE statement).

Go to Declaration

Corresponding elements in data sources.

Navigation | Jump to Query Console

Ctrl+Shift+F10

Open the list of query consoles for the selected data source.

Data sources and their elements (tables and table columns)

Run Function

or

Run Procedure

Run the selected function or procedure.

Data source elements: functions, procedures.

(Oracle only) Introspection Level

Change the introspection level either for the whole database or for a particular schema. Children inherit a level that is set for a parent.

Oracle Data Source nodes.

SQL Scripts | SQL Generator

Ctrl+Alt+G

Generate data definition structures for database objects. For example, you can generate DDL files for a single table or for all the tables in the schema. Also, you can customize generation settings. For example, you can set what syntax to use for table creation: CREATE TABLE or CREATE TABLE IF NOT EXISTS.

For more information, refer to the Generate DDL definitions for database objects and Change output settings of the SQL Generator chapters.

Data source elements.

SQL Scripts | Generate DDL to Clipboard

Ctrl+Alt+Shift+G

Generate a DDL of the object and copy it to the clipboard.

Data sources and their elements.

SQL Scripts | Truncate…

Remove all the rows in the selected table.

Data source elements: tables.

Tools | Manage Shown Schemas

Open a popup with available schemas for the current data source.

See also, Show and hide schemas.

Data sources and their elements.

Tools | Compare Structure

Ctrl+D

Compare structures of two selected database objects (data sources, schemas, or tables). The comparison results are shown in the Diff Viewer.

Data sources and their elements.

Tools | Full-text Search

Shift+Ctrl+Alt+F

Search for data in your databases or a group of databases without knowing the data's exact location.

Data sources and their elements.

Tools | Set Color

Set or change the color for the selected element or elements. (The Database Color Settings dialog will open.)

To set a color, right-click a data source and select Tools | Set Color. In the Database Color Settings dialog, select the dialog and coloring options. To have the data source color applied for query consoles and grids, select the In console editors and grids checkbox.

See also, Assign a color to query consoles and grids.

Data sources and their elements.

Tools | Add Bookmark

F11

Add the selected item to bookmarks.

Data sources and their elements.

Tools | Scripted Extensions | Generate POJOs.clj

Generate a Java entity class for the selected table. In the dialog that opens, specify the directory in which the JAVA class file should be generated.

Data sources and their elements.

Tools | Scripted Extensions | Go To Scripts Directory

Switch to the directory where the Generate POJOs.clj example script file is located.

Data sources and their elements.

Import/Export | Export Data to File

Save data for the selected tables and views in files. Select the output format (for example, SQL Inserts, Tab-separated (TSV), JSON-Clojure.json.clj).

Data source elements: tables and views.

Import/Export | Import Data from File(s)…

Import a text file containing delimiter-separated values (CSV, TSV, and so on) into your database.

If a schema is currently selected, CLion will create a new table for the data that you are importing. If a table is selected, CLion will try to add the data to the selected table.

Data source elements: tables.

Import/Export | Copy Table to

F5

Create a copy of the selected table. You can create a copy in a different scheme or data source. For example, you can copy the actor table from MySQL to PostgreSQL.

Database objects: tables and views.

Import/Export | Dump to DDL Data Source

Create your DDL data source by dumping a regular data source to a root/repository folder.

Data sources and their elements.

Import/Export | Export with 'mysqldump'

or

Import/Export | Export with 'pg_dump'

Run mysqldump or pg_dump for the selected items. mysqldump and pg_dump are native MySQL and PostgreSQL tools. They are not integrated into CLion. You can read about them at dev.mysql.com and postgresql.org.

Data source nodes.

Import/Export | Restore with 'mysql'

or

Import/Export | Restore with 'psql'

or

Restore

Run mysql, pg_restore, or psql to restore a data dump. These tools are native for MySQL and PostgreSQL. They are not integrated into CLion. You can read about them at dev.mysql.com and postgresql.org.

Data source nodes.

Diagrams | Show Visualisation

and

Diagrams | Show Visualisation Popup

Ctrl+Alt+Shift+U and Ctrl+Alt+U

View a UML class diagram for the selected data source or table. You can select between the following options:

  • Show Diagram to open the diagram in a separate editor tab.

  • Show Diagram Popup to see the diagram in a popup.

Data sources and their elements.

Diagnostics | Dump Metadata Model

(former Dump Model)

Generate a diagnostic representation of the database in a CLion internal format. This information might be helpful for the support team if some database objects exist in the database but do not show up in the Database tool window.

Data sources and their elements.

Diagnostics | Generate Introspector Diagnostic Files

(former Prepare Introspector Diagnostics)

Generate three files that include information about the following:

  • dataSource.txt: the data source.

  • introspector.txt: a module that was used to load the metadata from the database.

  • model.xml: a part of the database model.

This information might be helpful when introspection works incorrectly. For example, when you see something outdated or do not see new objects.

Data sources and their elements.

Diagnostics | Force Refresh

Ctrl+Shift+F5

Delete the data source information from cache and load it again. This action is available on the data source node only.

Data source nodes.

Diagnostics | Forget This Schema Cache

Delete the information that CLion has accumulated about your database. This action is available on the data source node only.

Use this command when you experience issues like wrong display of data structures or errors during synchronization.

To check if this has eliminated the problem, use the Synchronize command.

Data source nodes.

Diagnostic Mode

Enables the diagnostic mode where CLion writes the introspection log.

You can access the log file by clicking the link in the Diagnostic log started and Diagnostic log stopped notification popups that appear once you enable and disable the mode.

Notification about the log file

Icons

Data sources and their elements

Icon

Description

Access Method

Access Method

Aggregate

Aggregate

Alias Type

Alias Type

Argument

Argument

Body

Body

Check

Check

Cluster

Cluster

Collation

Collation

Collection Type

Collection Type

Column

Column. For more information about column icon combinations, refer to Possible icon combinations for columns.

Data File

Data File

Database

Database

Read-only

Read-only status

the DDL data source icon

DDL data source

Default

Default

Exception

Exception

Extension

Extension

External Schema

External Schema

Foreign Data Wrapper

Foreign Data Wrapper

Foreign Key

Foreign Key

Foreign Table

Foreign Table

Index

Index

Key

Key

Materialized Log

Materialized Log

Materialized View

Materialized View

Object Attribute

Object Attribute

Object Type

Object Type

Operator

Operator

Package

Package

Primary Key

Primary key

Projection

Projection

Data source

Data sources

Role

Role

Routine

Routine

Rule

Rule

Scheduled Event

Scheduled Event

Schema

Schema

Sequence

Sequence

Server

Server

the Stored procedure or function icon

Stored procedure or function

Synonym

Synonym

Table

Table

Table Type

Table Type

Tablespace

Tablespace

Trigger

Trigger

User

User

User Mapping

User Mapping

Variable

Variable

View

View

Virtual column

Virtual column

Virtual foreign key

Virtual foreign key

Virtual view

Virtual view

Virtual Table

Virtual Table

Possible icon combinations for columns

Icon

Foreign key

Primary key

Indexed

NOT NULL

Column

Column with a foreign key

Has a foreign key

Column with a primary key

Has a primary key

Indexed column

Indexed

Column that does not accept NULL values

Has the NOT NULL constraint

Indexed column that does not accept NULL values

Indexed

Has the NOT NULL constraint

Indexed column with primary and foreign keys that does not accept NULL values

Has a foreign key

Has a primary key

Indexed

Has the NOT NULL constraint

Indexed column with primary and foreign keys

Has a foreign key

Has a primary key

Indexed

Column with primary and foreign keys that does not accept NULL values

Has a foreign key

Has a primary key

Has the NOT NULL constraint

Column with primary and foreign keys

Has a foreign key

Has a primary key

Indexed column with a foreign key that does not accept NULL values

Has a foreign key

Indexed

Has the NOT NULL constraint

Column with a foreign key that does not accept NULL values

Has a foreign key

Has the NOT NULL constraint

Indexed column with a foreign key that accepts NULL values

Has a foreign key

Indexed

Indexed column with a primary key that does not accept NULL values

Has a primary key

Indexed

Has the NOT NULL constraint

Column with a primary key that does not accept NULL values

Has a primary key

Has the NOT NULL constraint

Indexed column with a primary key

Has a primary key

Indexed

Last modified: 12 November 2024