Database tool window | PyCharm (original) (raw)

Enable the Database Tools and SQL plugin

This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PyCharm 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 .
  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, 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.

Database tool 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 Data sources topic.

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

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.

Browse your databases

Find database objects

For more information about speed search, refer to Speed Search in tool windows.

Filter database objects

You can filter database objects and hide the objects you do not need to see. To do this, use either the object filter in data source settings or the tool window item filter.

Show more schemas

Database tool window displays introspected databases and schemas of your data sources. For a database or schema to be shown in the tree, select it in the schema selector of a data source.

For more information about introspection, refer to Glossary.

View a group in a table

View quick documentation

Scroll to the object opened in editor

Use folders in the tree

Database allows creating folders and grouping data sources in them. You can also move one folder to another and create subfolders. Folders configuration is stored in .idea/db-forest-config.xml. You can add this configuration file to the VCS to share it with your colleagues, or you can also ignore it in the VCS.

Move tree items to folders

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

Move an item to a folder

Reorder folders and data sources

To move folders and data sources in the tree, use the Move context menu actions and corresponding shortcuts.

Reorder folders in Database tool window

Configure the tree view

Customize the view of objects

Toggle groups for non-major objects

For more information about view options, refer to the Database topic.

Assign colors to data sources and database objects

To have better differentiation between databases, you can assign a color to a data source. The color can be enabled in Database, code editor and data editor tab headers, code editors and grids, and in toolbars.

  1. In Database tool window, right-click the data source and navigate to .
  2. In the Database Color Settings dialog, select the color that you want to assign and where to enable it.
    For more information about the settings in this dialog, refer to the Database Color Settings dialog reference topic.
  3. Apply the changes and close the dialog.

For more information about assigning color to a data source in its settings dialog, refer to Assign a color to a data source.

Show tree indent guides

In the Database tool window, you can display vertical lines that mark indent levels and help you better understand the hierarchy of the objects in your databases.

  1. Press Ctrl+Alt+S to open settings and then select .
  2. In the Tree Views section, enable the Show indent guides option.

Show comments and last refresh date

You can view comments and last refresh timestamps for the objects in the database tree.

Productivity tips

Create a quick table backup

For more information about the dialog, refer to Import dialog.

Reference info

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 HideShift+Escape Hide the tool window .To hide all the tool windows, press Ctrl+Shift+F12.
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.
Show Query Console Toolbar Display the toolbar in the query file tabs.
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 Tool window view 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: or press Alt+1.
Help This command opens the description of the Project tool window in the PyCharm online help.

Toolbar

Database tool window toolbar

the New icon

New

Create a new data source, query file, or a driver.

Available for: Data sources and database objects.

the Data Source Properties icon

Data Source Properties Shift+Enter

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

Available for: 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.

Available for: Data sources and their elements.

the Deactivate icon

Deactivate Ctrl+F2

Close the database connection for the selected data source or data sources.

Available for: Data sources with active connections and their elements.

the Jump to Query File icon

Jump to Query Console Ctrl+Shift+F10

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

Available for: Data sources and their elements.

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.

Available for: 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

Available for: Corresponding elements in data sources.

the Compare Structure icon

Compare Structure Ctrl+D

Compare the structure of two database objects in the Migration dialog. The comparison results are shown in the Diff Viewer.

Available for: 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.

Available for: All items.

View Options

The view options, generally, define what is shown in the tool window and how. To view or change these options, click View Options on the toolbar.

View Options menu items in Database tool window

the Filter icon Filter

Open a list of database objects that you can filter. The list of database objects depends on the selected database. To see a full list of available database objects and their icons, go to Icons for data sources and their elements.

The green dot in the corner of filter icon indicates that the filter is on and some objects are filtered out.

Everything is filtered out except views and tables

Only views and tables are selected to view in Database tool window

Nothing is filtered out

All items are selected to view in Database tool window

Displays folders for databases and schemas.

Displays folders for server and database objects, Server Objects and Database Objects correspondingly. This setting concerns users, roles, tablespaces, modules, foreign data wrappers, and other rarely used objects.

This option defines how table elements are shown.

Defines how schema elements are shown.

In Microsoft SQL Server, Oracle, and PostgreSQL, separates procedures and functions into different folders.

Display nodes for object names that exist in a schema namespace. For example, nodes for keys, CHECK constraints, indexes, triggers, rules, and other objects.

You can use this option in the following situations:

Order database objects alphabetically. When the option is disabled, the natural sort order is applied.

Show all databases and schemes even if they are not selected for introspection.

If the Schema Objects or Object Elements options are selected, you can select to show or hide the categories that contain no elements.

Shows or hides parent nodes only when you do not have other objects on the same level with a parent.

For Oracle, shows or hides auto-generated objects in the tree. It concerns the following objects:

Show or hides the following objects:

Display comments for database objects.

Display the local date and time of the last performed introspection for schemas.

The feature is currently not supported for ClickHouse, Redis, Apache Cassandra, and Apache Hive.

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

the Properties icon Properties Shift+Enter

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

Available for: Data source and DDL data source nodes.

the New icon New

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

Available for: Data sources and database objects.

Ctrl+C

Copy the XML code snippet with connection settings to the clipboard.

Available for: Data source nodes.

Ctrl+Alt+Shift+C

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

Available for: Data sources and their elements.

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.

Available for: Data source and DDL data source nodes.

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.

Available for: 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.

Available for: Data source and DDL data source nodes.

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.

Available for: Data sources and their elements.

the Deactivate icon Deactivate Ctrl+F2

Close the database connection for the selected data source or data sources.

Available for: Data sources with active connections and their elements.

Quick Documentation Ctrl+Q

View basic information about the selected element.

To close the documentation popup, press Escape.

Available for: Data sources and their elements.

For more information about quick documentation, refer to quick documentation.

the Compare Structure icon Compare Structure With Ctrl+D

Compare the structure of two database objects in the Migration dialog. The comparison results are shown in the Diff Viewer.

Available for: Two selected database objects of the same kind.

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

Available for: Corresponding elements in data sources.

Jump to Query Console Ctrl+Shift+F10

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

Available for: Data sources and their elements.

Run Function or Run Procedure

Run the selected function or procedure.

Available for: Data source elements: functions, procedures.

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.

Available for: Data Source nodes.

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.

Available for: Data source elements.

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

Requests the DBMS server to get or generate a source text for this object, receives this text, and puts it to the clipboard.

Available for: Data sources and their elements.

Ctrl+Alt+Shift+G

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

Available for: Data sources and their elements.

Ctrl+Alt+Shift+B

Generate a DDL of the object and copy it to the query file.

Available for: Data sources and their elements.

Shift+F6

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

Available for: Data sources and their elements.

Enable triggers and constraints for the selected table.

Available for: Data source elements: tables.

Disable triggers and constraints for the selected table.

Available for: Data source elements: tables.

Modify the database object comment in the Modify Comment dialog.

Modify the grants of a database object in the Modify Grants of <object_name> dialog.

Remove all the rows in the selected table.

Available for: Data source elements: tables.

or Delete

Remove the selected item.

Available for: Data sources and their elements.

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

See also, Show and hide schemas.

Available for: Data sources and their elements.

Shift+Ctrl+Alt+F

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

Available for: Data sources and their elements.

For more information about the full-text search, refer to Full-text search in databases.

Open the Database Color Settings dialog to set or change the color for the selected element or elements.

Available for: Data sources and their elements.

F11

Add the selected item to bookmarks.

Available for: Data sources and their elements.

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.

Available for: Data sources and their elements.

Switch to the directory where theGenerate POJOs.cljexample script file is located.

Available for: Data sources and their elements.

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).

Available for: Data source elements: tables and views.

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

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

Available for: Database tables.

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.

Available for: Database tables and views.

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

Available for: Data sources and their elements.

or

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

Available for: Data source nodes.

or 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 PyCharm. You can read about them at dev.mysql.com and postgresql.org.

Available for: Data source nodes.

Ctrl+Alt+Shift+U

View a UML class diagram for the selected data source or table in a separate editor tab.

Available for: Data sources and their elements.

View a UML class diagram for the selected data source or table in a popup.

Available for: Data sources and their elements.

Generate a diagnostic representation of the database in a PyCharm 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.

Available for: Data sources and their elements.

Generate three files that include information about the following:

This information is helpful when introspection works incorrectly.

Available for: Data sources and their elements.

Open the JDBC Log Setting dialog to configure the JDBC driver log settings.

Available for: Data sources and their elements.

Ctrl+Shift+F5

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

Available for: Data source nodes.

Delete the information that PyCharm 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.

Available for: Data source nodes.

Enables the diagnostic mode where PyCharm 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

01 December 2025