PyCharm 4.0.0 Web Help

2.0+

View | Tool Windows | Database

The Database tool window is the main access point to functions for working with databases (DB data sources) and DDL data sources.

The available data sources are shown as a tree of data sources, tables and table columns. If no data sources are currently defined, use the New command (Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter) to create a data source.

Most of the functions in this window are accessed by means of the toolbar icons or context menu commands. (If the toolbar is not currently shown, click viewMode on the title bar and select Show Toolbar.) Many of the commands have keyboard shortcuts. The Synchronize and Console commands can additionally be access by means of the title bar buttons (SynchronizeOnTitleBar and ConsoleOnTitleBar respectively).

The set of available functions depends, first of all, on the data source type (DB or DDL). For DB data sources you can, for example:

  • Create, modify and delete database tables, table columns, indexes, primary and foreign key constraints, etc. The following commands are provided for these purposes: New, Rename, Modify Column, Delete and Drop Associated (e.g. Drop Associated Primary Key).
  • Open the Table Editor to manipulate table data (the Table Editor command).
  • Open the database console to run DDL and DML SQL statements (the Console command).
  • Generate DDL definitions for databases and database tables. The corresponding definitions are generated on the clipboard by using the Copy DDL command, and then may be pasted into a file or the database console.
  • Save table data in various "most popular" formats (the Save to File command).

Irrespective of the data source type (DB or DDL), you can also:

  • Compare the data sources and tables (the Compare command).
  • View UML class diagrams for data sources and tables (the Diagrams command).
  • View basic information for data sources and their elements in a quick documentation pop-up.
  • Set and change colors for data sources, tables and columns (the Color Settings command).

viewMode on the title bar provides access to view options.

On this page:

View options

The view options, generally, define what is shown in the tool window and how. To view or change these options, click viewMode on the title bar.

Option Description
Flatten schemas This option defines how schemas are shown.

When off, there is a separate node for each of the schemas.

DBFlattenSchemasOff

When on, the schemas themselves are not shown; the schema names appear as prefixes of the table names.

DBFlattenSchemasOn

Group Tables by Type When this option is off, all the tables are ordered alphabetically by their names.

DBGroupTablesByTypeOff

When this option is on, the tables are grouped. The group of base tables (tables) is shown first. After the base tables, virtual tables (views) are shown. Within the groups, the tables are ordered alphabetically.

DBGroupTablesByTypeOn

Sort Columns When this option is off, the columns, generally, are unsorted.

DBSortColumnsOff

When this option is on, the columns are ordered like this: the columns with a primary key, then the columns with a foreign key, and then the rest of the columns. Within the groups, the columns are ordered alphabetically.

DBSortColumnsOn

Show Table Constraints When this option is on, the public and foreign key constraints, and indexes are shown.

DBShowTableConstraintsOn

Otherwise, the constraints are not shown.

DBShowTableConstraintsOff

Show Toolbar Select or deselect this option to show or hide the toolbar.

The rest of the options are common for all the tool windows, see Viewing Modes.

Toolbar icons, context menu commands and shortcuts

Icon Command Shortcut Description Available for
img New Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter Use this icon, command or shortcut to create a new data source, table, column, index, or primary or foreign key. The list of options depends on which element is currently selected. You can choose:
  • DataSource Data Source to create a new DB data source. Select the DBMS and specify the settings for the new data source in the Data Sources and Drivers dialog.
  • icon_SqlDataSource DDL Data Source to create a new DDL data source. Specify the settings for the new data source in the Data Sources and Drivers dialog.
  • icon_DataSourceImport.png Import from sources to create one or more DB data sources by importing the files that contain database connection settings (the database URL, driver class, user name and password).

    PyCharm will scan your project and, if the appropriate files are found, the Data Sources and Drivers dialog will open.

    The names of candidate data sources will be shown in green in the left-hand pane under Data Sources.

    See also, Importing a DB data source.

  • DataTables Table to create a new table for a selected DB data source.
  • dataColumn Column to create a column in the selected table.
  • dataIndex Index to create an index on the selected column or columns.
  • dataPrimaryKey Primary Key to define a primary key constraint on the selected column or columns.
  • dataForeignKey Foreign Key to define a foreign key constraint on the selected column or columns.
DB data sources and their elements (tables and table columns). If a DDL data source is selected, you can only choose to create another data source.
stop Disconnect Use this icon or command to close the database connection for the selected DB data source or data sources. (Data sources with active database connections have the text [connected] to the right of their names.)

See also, Database connections.

DB data sources with active connections and their elements
Drop Associated Use this command to remove constraints such as a primary key or a foreign key constraint. Choose:
  • dataPrimaryKey Primary Key to remove the corresponding primary key constraint. The command is available for a table or any of its columns if the table has a primary key.
  • dataForeignKey Foreign Key to remove the corresponding foreign key constraint. The command is available only for a column or columns on which a foreign key constraint is defined.
Tables and table columns in DB data sources
Rename Shift+F6Shift+F6Shift+F6Shift+F6Shift+F6Shift+F6Ctrl+RShift+Alt+RShift F6Shift F6Shift F6 Use this command or shortcut to rename the selected data source, table or table column. Specify the new name in the dialog that opens. All node types
img Duplicate Ctrl+DCtrl+DCtrl+DCtrl+DMeta+DCtrl+DCtrl+D, Ctrl+Shift+Down or Ctrl+Shift+UpCtrl+DCommand DCommand DCommand D Use this icon, command or shortcut to create a copy of the selected data source. Specify the properties of the data source in the Data Sources and Drivers dialog that opens. See Data Sources and Drivers Dialog. DB and DDL data source nodes
Modify Column Ctrl+F6Ctrl+F6Ctrl+6Ctrl+F6Ctrl+F6Ctrl+F6Ctrl+F6Shift+Alt+CCommand F6Command F6Alt Command C Use this command or shortcut to edit the properties of the selected column. Table columns in DB data sources
Copy Reference Ctrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CCtrl+Shift+Alt+CShift Alt Command CShift Alt Command CShift Alt Command C Use this command or shortcut to copy the fully qualified name of the selected data source, table or table column to the clipboard. All node types
Delete DeleteDeleteDeleteDeleteDelete or Ctrl+DDeleteDeleteDeleteDelete, Backspace or Command BackspaceDelete, Backspace or Command BackspaceDelete, Backspace or Command Backspace Use this command or shortcut to delete the selected data source, table or table column. All node types
Find Usages Alt+F7Shift+Alt+7Shift+Alt+7Alt+F7Alt+F7 or Shift+Alt+SShift+Alt+F7Alt+F7Ctrl+GAlt F7Alt F7Shift Command G Use this command or shortcut to find the usages of (references to) the selected item (data source, table or table column) in the project source files and libraries. All node types
showAllPAthsAffected Compare Ctrl+DCtrl+DCtrl+DCtrl+DCtrl+DCtrl+DCtrl+DCtrl+DCommand DCommand DCommand D Select two data sources or tables and then use this icon, command or shortcut to compare the selected items. The differences are shown in Differences Viewer for Folders and DB Objects. DB and DDL data sources and tables
DataTables Table Editor F4F4F4F4F4F4F4F12 or Ctrl+Shift+ECommand Down or F4F4F3 Use this icon, command or shortcut to open the selected database table in the Table Editor.

See also, Working with the Table Editor.

Tables and table columns in DB data sources
DataTables View Editor,
Function Editor,
Procedure Editor or
Package Editor
F4F4F4F4F4F4F4F12 or Ctrl+Shift+ECommand Down or F4F4F3 Use this icon, command or shortcut to open the definition of the selected view, function, procedure or package in the editor. Corresponding elements in DB data sources
DataTables Edit Source F4F4F4F4F4F4F4F12 or Ctrl+Shift+ECommand Down or F4F4F3 Use this icon, command or shortcut to open the associated DDL file in the editor. Tables and table columns in DDL data sources
runJdbcConsole Console Ctrl+Shift+F10Ctrl+Shift+F10Ctrl+Shift+F10Ctrl+Shift+F10Ctrl+Shift+F10Ctrl+F9Shift+Alt+F6 or Shift+F6Ctrl+Shift+F10Control Shift RControl Shift F10Control Shift R Use this icon, command or shortcut to open the database console for the corresponding DB data source. As a result, you'll be able to run DDL and DML SQL statements to manipulate data structures and data. DB data sources and their elements (tables and table columns)
img Synchronize Ctrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YCtrl+Alt+YAlt Command YAlt Command YAlt Command Y Use this icon, command or shortcut to update the view of the selected element (i.e. to synchronize the view of the element with its actual state in the database).

Note that you can enable auto-synchronization for a DB data source by turning on the Auto sync option in the Data Sources and Drivers dialog.

DB data sources and their elements (tables and table columns)
iconManageDataSources Data Source Properties Use this icon or command to open the Data Sources and Drivers dialog to manage your data sources and their settings. DB and DDL data source nodes
DDLCopy Copy DDL Ctrl+Shift+CCtrl+Shift+CCtrl+Shift+CCtrl+Shift+CCtrl+Shift+CCtrl+Shift+CCtrl+Shift+CCtrl+Shift+CShift Command CShift Command CShift Command C Use this icon, command or shortcut to copy a DDL definition of the selected data source, table or column onto the clipboard. All node types
Save to File Use this command to save the selected table in a file, or to view or edit the output format settings. Select the resulting format or Configure Extractors. In the latter case, the Data Extractors dialog will open and you'll be able to edit the settings for existing formats, and create new output formats. Tables in DB data sources
Color Settings Use this command if you want to set or change the color for the selected element or elements. (The Database Color Settings dialog will open.) All node types
icon_UML Diagrams Ctrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UCtrl+Shift+Alt+UShift Alt Command UShift Alt Command UShift Alt Command U
Ctrl+Alt+UCtrl+Alt+UCtrl+Alt+UCtrl+Alt+UCtrl+Alt+UCtrl+Alt+UCtrl+Alt+UCtrl+Alt+UAlt Command UAlt Command UAlt Command U
Use this icon, command or shortcut to see a UML class diagram for the selected data source or table. Select:
  • Show Visualisation to open the diagram on a separate editor tab.
  • Show Visualisation Popup to see the diagram in a pop-up window.
DB and DDL data sources and tables
collapseAllDB Use this icon to collapse all the nodes. As a result, only your data sources will be shown (i. e. the topmost hierarchy level).

Alternatively, icon_collapse_all_on_title_bar on the title bar can be used.

All node types
Ctrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+QCtrl+Q or Alt+Button2 ClickAlt+Button2 Click, Ctrl+Shift+Space or F2F1, Control J or Control Button2 ClickControl J or Control Button2 ClickAlt Button2 Click or F2 Use this key combination to see basic information for the selected element. The information shown depends on the element type. For example, the following is shown for a table: the names of the data source, catalog, schema and the table itself. Also shown is the corresponding CREATE TABLE DDL statement and, if appropriate, the first 10 table rows.

To close the documentation pop-up, press EscapeEscapeEscapeEscapeEscape, Escape or Ctrl+GEscapeEscapeEscapeEscapeEscapeEscape.

All node types

Icons for data sources and their elements

Icon Description
DataSource DB data source. Also, DBMS-specific icons are used:

DBDB2 DB2

DBDerby Derby

DBH2 H2

DBHSQLDB HSQLDB

DBMySQL MySQL

DBODBC ODBC

DBOracle Oracle

DBPostgresql PostgreSQL

DBSQLServer SQL Server

DBSQLite SQLite

DBSybase Sybase

DBReadonly DB data source with the read-only status, e.g. DBReadonlyDB2 for DB2.
icon_SqlDataSource DDL data source
dataSchema.png Schema
DataTables Table
dataColumn Column
dataColumnNotNull A NOT NULL column
dataPkColumn.png Column with a primary key
dataFkColumn.png Column with a foreign key
dataIndexedColumn.png Column with an index
dataPrimaryKey Primary key
dataForeignKey Foreign key
dataIndex Index
dataView View
dataFunction Stored procedure or function

See Also

Language and Framework-Specific Guidelines:

Getting Started:

Web Resources: