View | Tool Windows | Database

Use the Database tool window to:

  • Manage available data sources. (These are shown as a tree of data sources, tables and table columns.)
  • View open database connections and close the unnecessary ones.
  • View the structure of tables within data sources in a UML class diagram.
  • View table information in a quick documentation pop-up window.

In this section:

Context menu

ItemIconShortcutDescriptionAvailable in
Add Data SourceimgAlt+Insert Choose this command to create a new data source.

Select the data source type or the import command:

  • DataSource DB Data Source. Select this command to create a new DB data source. Specify the properties of the new data source in the DB Data Source Properties dialog.
  • icon_SqlDataSource DDL Data Source. Select this command to create a new DDL data source. Specify the properties of the new data source in the DDL Data Source Properties dialog.
  • icon_DataSourceImport.png Import from Project Files. Select this command to create one or more data sources by importing the corresponding configuration files. Select the configuration files of interest in the Import Data Sources dialog.
All contexts
RemoveimgDeleteChoose this command to remove the selected data source entry from the list.Data source node
Close Database Connectionstop.gifDeleteChoose this command to close the selected active database connection. Note that PyCharm opens connections when necessary without any steps from your side, and displays them beneath the corresponding data source nodes.Active connection
Copy Data SourceimgCtrl+DChoose this command to have a copy of the current data source created with the incremental name.Data source node
Copy ReferenceCtrl+Alt+Shift+CChoose this command to copy the fully qualified name of the selected item to the clipboard.All contexts
Data Source PropertiesimgEnterChoose this command to view or edit the properties of the selected data source. Depending on the data source type, one of the following dialogs will open: Data source node
Find UsagesAlt+F7Select the desired node (data source, schema, table, column) and press Alt+F7. The usages of tables and columns include database schema usages, i.e. references in indices, primary and foreign keys.All contexts
CompareshowAllPAthsAffectedCtrl+DSelect two nodes, and choose this command on the context menu. The differences are shown in Differences Viewer for Folders and DB Objects.All contexts
Refresh TablesimgCtrl+Alt+YChoose this command to have the current data source updated and the database tables loaded.All contexts
Open Database ConsolerunJdbcConsole.pngCtrl+Shift+F10Choose this command to run the Database console.All contexts
Open Table Editoropen_table_editor.pngF4Choose this command to open the selected database table in the Table Editor.

The Table Editor is available only for the DB type data sources.

See also, Manipulating Table Data in the Table Editor.

DB table node
Generate and Copy DDLicon_sqlOpenInEditor.pngCtrl+C or Ctrl+InsertChoose this command to have data structure definition statements generated based on the selected node.

The generated statements are stored in the clipboard.

All contexts
Diagramsicon_UML.pngCtrl+Shift+Alt+U
Ctrl+Alt+U
Choose this command, and then select one of the possible ways to view database structure:
  • Show Visualization. A UML class diagram is shown on a separate editor tab.
  • Show Visualization Popup. A UML class diagram is shown in a pop-up window.
All contexts
View table dataCtrl+QChoose the desired table and press Ctrl+Q to view the create table query for the table and its first 10 rows.

This action has no command on the context menu.

All contexts, except for connection nodes.

Tree view nodes

IconDescription
DataSource DB data source
icon_SqlDataSource DDL data source
dataSchema.png Schema
DataTables.png Table
dataColumn.png Column
dataPkColumn.png Column with a primary key
dataFkColumn.png Column with a foreign key
dataIndexedColumn.png Column with an index
dataPrimaryKey.png Primary key
dataForeignKey.png Foreign key
dataIndex Index
database_connection.png Database connection node for a data source.

PyCharm establishes a database connection automatically first time it needs to execute a query, and closes it automatically upon the session end. If necessary, a connection can be terminated manually, using the context menu command Close Database Connection stop.

See Also

Language and Framework-Specific Guidelines:

Getting Started:

Web Resources: