PhpStorm 2018.2 Help

Database Tool Window

View | Tool Windows | Database


Overview

The Database tool window provides access to functions for working with databases and DDL data sources. It lets you view and modify data structures in your databases, and perform other associated tasks.

For more information, see Working with the Database tool window.

DBToolWindow

The available data sources are shown as a tree of data sources, schemas, tables and columns. If no data sources are currently defined, use the New command (Alt+Insert) 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 icons general gearPlain svg on the title bar and select Show Toolbar.) Many of the commands have keyboard shortcuts. If the toolbar is hidden, the Synchronize and Open Console commands can be access by means of the title bar icons (SynchronizeOnTitleBar and respectively).

Toolbar icons, context menu commands and shortcuts

Icon

Command

Shortcut

Description

Available for

icon collapse all on title bar

Collapse all the nodes.

All node types

icons general add svg

New

Alt+Insert

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

See also, Creating a data source, Creating a database or schema, Creating and opening a new database console, Creating a table, a column, an index, or a primary or foreign key and Data Sources and Drivers Dialog.

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

icons actions copy svg

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.

DB and DDL data source nodes

icons actions refresh svg

Synchronize

Ctrl+Alt+YUpdate the view of the selected element (i.e. synchronize the view of the element with its actual state in the database).

See also, Auto sync.

DB data sources and their elements

iconManageDataSources

Properties

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

All node types

icons actions suspend svg

Disconnect

Ctrl+F2

Close the database connection for the selected DB data source or data sources. (The names of the data sources with active database connections are shown in bold.)

DB data sources with active connections and their elements

DataTables or iconDBEditDDLSource

Open Editor

F4 or Ctrl+B

Open the data editor or the definition editor for the selected item.

Corresponding elements in DB data sources

runJdbcConsole

Open Console

Ctrl+Shift+F10

Open the default database console for the corresponding DB data source.

DB data sources and their elements (tables and table columns)

Rename

Shift+F6 Rename the selected data source, table or column. Specify the new name in the dialog that opens.

See also, Renaming items.

All node types

Modify Table,
Modify Column,
Modify Index,
Modify Key,
Modify Foreign Key

Ctrl+F6

Edit the definition of the selected table, column, index, or primary or foreign key.

See also, Modifying the definition of a table, column, index, or a primary or foreign key.

Corresponding elements in DB data sources

Copy Reference

Ctrl+Shift+Alt+C

Copy the fully qualified name of the selected data source, table or column to the clipboard.

All node types

Find Usages

Alt+F7

Find the usages of (references to) the selected item (data source, table or column) in your source files and libraries.

All node types

Database Tools | Hide Schemas

Hide the selected schemas. See Showing and hiding schemas.

Schemas in DB data sources

Database Tools | Manage Shown Schemas

Open the Schemas popup for the current DB data source. See Showing and hiding schemas.

DB data sources and their elements

Database Tools | Forget Cached Schema

Use this command in problematic cases such as when your data structures start to display incorrectly, fail to synchronize, etc. As a result, PhpStorm deletes the information it has accumulated about your database.

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

DB data sources

Database Tools | Copy Settings

Copy the settings for the selected data source onto the clipboard.

DB data sources

Database Tools | Drop Primary Key

Remove the primary key constraint for the current table.

Tables and columns in DB data sources

Database Tools | Drop Foreign Key

Remove the foreign key constraint.

Columns with the foreign key constraint in DB data sources

Database Tools | Truncate

Remove all the rows in the selected table.

Tables in DB data sources

Drop or Remove

Delete

Remove the selected item.

All node types

Open New Console

Create and open a new database console for the corresponding DB data source.

DB data sources and their elements

Generate and Copy DDL

Ctrl+Shift+C

Generate DDL definitions for the selected data source, schema, table, view, stored procedure or function, and copy those definitions onto the clipboard.

All node types except columns

Open DDL in Console

Shift+F4

Open a DDL definition of the selected table or view in a database console.

Tables and views in DB data sources

Compare

Ctrl+D

Select two data sources, schemas or tables and then use this command to compare table structures for the selected items. The comparison results are shown in the differences viewer differences viewer.

DB and DDL data sources and tables

Dump Data to File(s)

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

See also, Saving data in files in various forms and formats.

DB data sources, and schemas, tables and views within them

Dump with "mysqldump" or Dump with "pg_dump"

Run mysqldump or pg_dump for the selected items. See Creating database backups with mysqldump or pg_dump.

MySQL and PostgreSQL data sources, and schemas, tables and views within them

Import Data from File

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

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

See Importing delimiter-separated values into a database.

Schemas, tables and columns in DB data sources. For columns, the result will be the same as for schemas

Restore with "mysql", Restore with "psql" or Restore

Run mysql, pg_restore or psql to restore a data dump.

See Restoring data dumps with mysql, pg_restore or psql.

MySQL data sources, databases and schemas. PostgreSQL data sources, databases, schemas and tables

Color Settings

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

All node types

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.

Tables

Scripted Extensions / Go to Scripts Directory

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

All node types

Diagrams

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

View 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

View | Quick Documentation (in the main menu)

Ctrl+Q View basic information about the selected element. For example, the info about a table includes the names of the data source, database, schema and the table itself, the table definition (CREATE TABLE) and, if appropriate, the first 10 rows.

To close the documentation pop-up, press Escape.

All node types

View options

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

Option

Description

Group Schema

This option defines how schema elements are shown.

When on, there are separate nodes for tables, views and stored routines (shown as folders). Tables, views and routines (procedures and functions) are shown as elements of the corresponding groups.

DBGroupSchemaOn

When off, there is no explicit grouping for tables, views, and routines. Tables and views are followed by procedures and functions.

DBGroupSchemaOff

Group Contents

This option defines how table elements are shown.

When on, there are separate nodes for columns, indexes, primary and foreign key constraints, and triggers (shown as folders). The elements appear in the corresponding groups.

DBGroupContentsOn

When off, there is no such grouping and, generally, only columns are shown for tables.

DBGroupContentsOff

Show Keys and etc.

When this option is on, the primary and foreign key constraints, and indexes are shown as separate elements.
DBShowTableConstraintsOn

Otherwise, there are no separate elements for the keys and indexes.

DBShowTableConstraintsOff

The option is unavailable when the Group Contents option is on.

Show Empty Groups

If the Group Schema or the Group Contents option is on, you can select to show or hide empty groups, i.e. the categories that contain no elements.

The Show Empty Groups option is on:

DBShowEmptyGroupsOn

The Show Empty Groups option is off:

DBShowEmptyGroupsOff

Show Intermediate Nodes

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

Enabled

Disabled

db show intermediate nodes enabled
db show intermediate nodes disabled

Sort Alphabetically

When this option is off, columns, generally, are unsorted.
DBSortColumnsOff

When this option is on, the columns are ordered alphabetically.

DBSortColumnsOn

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 Tool Windows Viewing Modes.

Icons for data sources and their elements

Icon

Description

DataSource

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

DBReadonly

DB data source with the read-only status, e.g. DBReadonlyDB2 for Derby.

icon DDLDataSource

DDL data source

Database

dataSchema

Schema

DataTables

Table

dataView

View

icons nodes 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

dataTrigger

Trigger

Stored procedure or function

Title bar context menu and buttons

You can right-click on the window title bar 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

icon collapse all on title barCtrl+NumPad -

Use this button to collapse all expanded nodes in the current view.

icons general gearPlain svg

Click this button to access a subset of the context menu commands that let you configure window's viewing mode.

icons general hideToolWindow svgShift+Escape Use this icon or shortcut to hide the tool window.

When used in combination with the Alt key, clicking this icon hides all the tool windows attached to the same tool window bar.

Last modified: 21 November 2018

See Also