PhpStorm 2023.3 Help

Glossary for the database management functionality

Enable the Database Tools and SQL plugin

This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in PhpStorm by default. If the relevant features aren't available, make sure that you didn't disable the plugin.

  1. Press Ctrl+Alt+S to open the IDE 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.

Connection to a database

To connect to a database, PhpStorm requires connection details (for example, host, port, password, SSH configuration settings, and so on). For every database, the connection details are stored in a dedicated connection configuration — data source.

For a data source, connections to the database are established in special wrappers — sessions. Each session is a wrapper over a single connection, and it stores the connection's information (for example, whether it is active or not, transaction control mode, and other settings).

A connection within a session appears when you perform an action that requires interaction with the database.

For example, once you double-click a table under a data source in Database tool window, a new session is created, connected, and it has the data editor as its client. PhpStorm requires an active connection to request the table data from the database, receive it, and display it in the data editor.

For more information about connecting to databases, refer to the Connection to a database topic.

Data source

Data source is a connection configuration. It stores a list of connection details that are used to establish connection to a database. For example, host, port, database name, driver, SSH and SSL configuration settings, and so on. In data source settings, you can also select databases and schemas for introspection and display in Database tool window, and change the driver for your connection.

Data source with connection details for a PostgreSQL database

You can see the list of created data sources in the Database tool window ( View | Tool Windows | Database) . Data sources with an active connection to a database are marked with a green dot in the corner of their icons.

Data sources in the Database tool window

For more information about creating a data source for the supported database vendors, refer to the Create a data source section.

For more information about managing data sources, refer to the Data sources topic.

For more information about the Data Sources and Drivers dialog, refer to the Data Sources and Drivers dialog topic.

DDL data source

DDL data source is a virtual view of a database structure based on SQL files that contain data definition language statements (DDL statements). You can reference all tables, columns and other objects defined in such files in the editor. Diagrams are also supported.

DDL data source lets you maintain database versioning. Keep the SQL files under a VCS system and regenerate them every time your database structure is updated.

Once created, DDL data sources are available in Database tool window ( View | Tool Windows | Database) . You can create and manage the SQL files with statements in the Project tool window ( View | Tool Windows | Project) .

DDL data source in Database tool window and SQL files with statements in Project tool window

For more information about DDL data sources, refer to the DDL data sources topic.

Session

Each session is a wrapper over a single connection, and it stores the connection's information (for example, whether it is active or not, transaction control mode, and other settings).

Sessions can have clients — files, whose queries are sent via the connection that the session holds. Data editor can also be a client for a session.

For example, once you double-click a table in Database tool window, a new session connects to the database, and the table is attached to the session as its client.

You can view data sources, sessions, and session clients in the Services tool window. Green dot in the corner of session's icon indicates a connected session.

For more information about sessions, refer to Sessions.

Data editor and viewer

The data editor and viewer, or data editor, provides a user interface for working with data. In the data editor, you can sort, filter, add, edit, and remove the data as well as perform other associated tasks.

In PhpStorm, the data editor and viewer lets you work with database object data, query results sets, and also DSV files data.

Data editor tab
Data editor in a Result tab
Data editor in the in-editor results
Data editor tab in a delimiter-separated values file editor

For more information about data editor, refer to Data editor and viewer.

Database tool window

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

the Database tool window

For more information about working with database objects in Database tool window, refer to the Database objects section.

For more information about Database tool window, refer to the Database tool window topic.

Introspection

Introspection is the process of loading the metadata of the database objects (for example, object names and types of columns) and source code. PhpStorm uses this information to show the objects in Database tool window, display their DDL, suggest them during completion, and for other coding assistance features.

By default, only the schemas and databases selected to be shown in the Database tool window are introspected. Depending on the database size, the metadata that was loaded during its introspection can take a significant amount of time and disk space.

Once the necessary databases and schemas are introspected, IDE can resolve the database objects in your scripts to the correct context, depending on the attached session and resolve mode.

Oracle users might experience a long introspection time if all the objects are being processed, whereas it is usually not required for daily work and coding assistance. To reduce the amount of introspected objects, PhpStorm has three introspection levels available for Oracle databases. For more information about them, refer to Oracle introspection levels.

For more information about troubleshooting an incorrect introspection, refer to the Reporting introspection issues topic.

Query console

Query or database consoles are SQL files that are attached to a data source. You can write and execute SQL statements in query consoles the same way as you do it in terminal.

When you create a data source, the data source's default query console is created automatically. If necessary, you can create additional query consoles.

Query console

For more information about query consoles, refer to the Query consoles topic.

For more information about other types of SQL files in PhpStorm, refer to the File management topic.

User files

User files are the files that are stored on your machine or any other place you have access to. To work with them in PhpStorm, access the directory that contains them in the Project tool window .

For more information about user files, refer to the User files topic.

For more information about other types of SQL files in PhpStorm, refer to the File management topic.

Last modified: 25 March 2024