DataGrip 2021.2 Help

Quick start with DataGrip

This quick start guide will introduce you to the key concepts and help you with your first steps in DataGrip.

Also, you can check our introduction video that covers all major topics about the IDE: adding data sources, configuring connection options, working in the editor, and installing plugins.

Step 1. Configure initial settings

After you have installed the product and launched it for the first time, you see the initial configuration wizard. You can see a more detailed description of the installation process in Install DataGrip.

  1. On the first page, select the color scheme for DataGrip, which can be either light or dark.

  2. On the second page, you can configure the default dialect and a directory with SQL scripts.

    Default SQL dialect: code in SQL files is highlighted according to the selected dialect. For example, if you select Microsoft SQL Server, the SQL files will be highlighted as SQL Server files by default. You can change this setting later. To set a dialect for a file or a folder, see SQL Dialects.

    Scripts directory: a directory that is attached in the Files tool window (View | Tool Windows | Files). You can attach any directory later.

    Configure initial settings

Step 2. Enable Docker and Git plugins

We are going to need Docker and Git plugins to run the PostgreSQL instance and clone git repositories. Ensure that these plugins are installed and enabled. If you want to use your DBMS and your scripts, feel free to skip this step.

Enable the Git plugin by JetBrains

  1. Press Ctrl+Alt+S to open IDE settings and select Plugins.
  2. Click Installed.

  3. In the search field, type Git, and press Enter.

  4. Select the checkbox near the Git plugin name. To add integration with GitHub, you can also enable the GitHub plugin.

  5. Restart the IDE.

Install the Git plugin by JetBrains

Install the Docker plugin by JetBrains

To Docker support in DataGrip, install the Docker plugin by JetBrains.

  1. Press Ctrl+Alt+S to open IDE settings and select Plugins.
  2. Click Marketplace.

  3. In the search field, type Docker, and press Enter.

  4. To install the plugin, click Install and restart DataGrip.

Install the Docker plugin by JetBrains

Step 3. Clone repositories

For example purposes, we are going to use the following two repositories: Sakila dump files ( and Docker-compose files ( Sakila repository includes scripts that generate the structure of the Sakila database and scripts that add data to database objects. Docker repository includes YAML files that define services, networks, and volumes.

Enable version control integration

  1. Click VCS | Enable Version Control Integration.

  2. In the Enable Version Control Integration dialog, ensure that Git is selected in the drop-down list and click OK.

    Enable version control integration

Clone repositories

  1. Click Git | Clone.

  2. In the URL field, copy and paste the following web URL:

    • Sakila dump files:

    • Docker-compose files:

  3. In the Directory field, click the folder icon (The folder icon) and specify a directory for the repository files.

    Clone repositories

Step 4. Run the Docker database image

For this tutorial, we are going to run a PostgreSQL container for Docker (from the datagrip-documentation repository). In the Docker directory of the repository, you can find .env and docker-compose.yml files. .env includes credentials for the PostgreSQL service. docker-compose.yml defines how the service is created and configured.

The service name is the first line of the service definition (before the JDBC URL). In our example, the service name is postgresql_12, the JDBC URL is jdbc:postgresql://localhost:54333/guest?user=guest&password=guest.

postgresql_12: # jdbc:postgresql://localhost:54333/guest?user=guest&password=guest container_name: postgresql_12 ports: - "54333:5432" image: postgres:12-alpine env_file: .env healthcheck: test: "exit 0"

You can run the container from a command line by running:

docker-compose up -d postgresql_12
Note that you must navigate to the directory of the docker-compose.yml file first.

Alternatively, you can enable and use the Docker plugin in DataGrip.

Enable Docker support

  1. Install and run Docker.

    For more information, see the Docker documentation.

  2. Configure the Docker daemon connection settings:

    • Press Ctrl+Alt+S to open IDE settings and select Build, Execution, Deployment | Docker.

    • Click The Add button to add a Docker configuration and specify how to connect to the Docker daemon.

      The connection settings depend on your Docker version and operating system.

      The Connection successful message should appear at the bottom of the dialog.

      The Docker connection settings
  3. Connect to the Docker daemon.

    The configured Docker connection should appear in the Services tool window (View | Tool Windows | Services or Alt+8). Select the Docker node Docker node and click The Connect button, or select Connect from the context menu.

    The Docker tool window, connected to Docker

    To edit the Docker connection settings, select the Docker node and click The Edit Configuration button on the toolbar, or select Edit Configuration from the context menu.

Create the Docker-compose deployment configuration

  1. In the Services tool window (View | Tool Windows | Services), right-click the Docker node and select Deploy.

  2. In the popup window, select Create Docker-compose Deployment.

  3. In the Create Deployment Configuration dialog, click the Browse icon of the Compose file(s) field.

  4. In the Docker Compose Configuration Files dialog, click the Add button and navigate to the compose file. The Compose YAML file defines services, networks, and volumes. In our case, it is docker-compose.yml

  5. In the Docker Compose Configuration Files dialog, click OK.

  6. In the Service(s) field, type postgresql_12.

  7. Click Run.

    As a result, you can see the postgresql_12 running container in the Services tool window.

    Create the Docker-compose deployment configuration

Step 5. Connect to a database

Depending on a database vendor (MySQL, PostgreSQL, Oracle), you need to create a corresponding data source connection. In this tutorial, we will create a PostgreSQL connection.

If you want to connect to other database management systems (DBMS), refer to Database connection. If you cannot connect to

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources.

    • Press Ctrl+Alt+Shift+S.

    • In the Database tool window (View | Tool Windows | Database), click the Data Source Properties icon The Data Source Properties icon.

  2. In the Data Sources and Drivers dialog, click the Data Sources tab.

  3. Click the Add icon (The Add icon) and select PostgreSQL.

  4. At the bottom of the data source settings area, click the Download missing driver files link. As you click this link, DataGrip downloads drivers that are required to interact with a database. The IDE does not include bundled drivers in order to have a smaller size of the installation package and to keep driver versions up-to-date for each IDE version.

    You can specify your drivers for the data source if you do not want to download the provided drivers. For more information about creating a database connection with your driver, see Add a user driver to an existing connection.

  5. In the URL field, copy and paste the JDBC URL: jdbc:postgresql://localhost:54333/guest?user=guest&password=guest.

  6. (Optional) In the Name field, delete the current name and type a new name for the connection (for example, PostgreSQL).

  7. To ensure that the connection to the data source is successful, click the Test Connection link.

Integration with PostgreSQL

Step 7. Attach a directory with SQL scripts

To run SQL scripts, you can right-click the data source and select Run SQL script. Alternatively, you can attach a folder with these scripts to the Files tool window and run them from here.

  1. Navigate to View | Tool Windows | Files.

  2. In the Files tool window, right-click any area and select Attach Directory to Project.

  3. Navigate to the directory that you want to attach. In our case, it the dumps directory.

  4. Click OK.

    Attach a directory with SQL files

Step 8. Run dump files

  1. In the Files (View | Tool Windows | Project) tool window, navigate to the postgres-sakila-db tree node.

  2. Expand postgres-sakila-db tree node.

  3. Hold Ctrl and click postgres-sakila-schema.sql and postgres-sakila-insert-data.sql.

  4. Right-click the selection and click Run '<file_names>'. Alternatively, press Ctrl+Shift+F10.

  5. In the Target data source / schema table, click the Add button (The Add button) and select PostgreSQL.

  6. Ensure that the postgres-sakila-schema.sql file is on top of the list in the Execute table. Otherwise, use Up (the Up button) and Down (the Down button) buttons to change the order of files.

    DataGrip executes files from the top of the list.

  7. Click Run.

    Run dump files

Step 9. Write your code

As you work in the editor, DataGrip analyzes your code, searches for ways to optimize it, and detects potential and actual problems. The following list includes basic features and tools that might be useful for your code writing and increase your productivity:

Code completion

  • Suggestions for code completion appear as you type your code. DataGrip has two types of code completion:

    Basic code completion Ctrl+Space helps you complete names of types, interfaces, methods, and keywords within the visibility scope. When you invoke code completion, DataGrip analyzes the context and suggests the choices that are reachable from the current caret position. By default, DataGrip displays the code completion popup automatically as you type.

    Smart code completion Ctrl+Shift+Space filters the suggestions list and shows only the types applicable to the current context.

    The following animation shows the difference between basic and smart completion. Notice the number of variants that are suggested for different completion types

Generating code

  • DataGrip provides multiple ways to generate common code constructs and recurring elements, which helps you increase productivity. These can be either file templates used when creating a new file, custom or predefined live templates that are applied differently based on the context, various wrappers, or automatic pairing of characters.

    From the main menu, select Code | Generate Alt+Insert to open the popup menu with available constructs that you can generate.

    You can generate functions, procedures, views, and other database objects.

    To generate an object, press Alt+Insert and select the object that you want to generate.

    Generating code

Live templates

  • Use live templates to insert common constructs into your code, such as statements or definitions of database objects.

    The following video shows how you can use live templates.

    To expand a code snippet, type the corresponding template abbreviation and press Tab. Keep pressing Tab to jump from one variable in the template to the next one. Press Shift+Tab to move to the previous variable.

    To see the list of live templates, open settings Ctrl+Alt+S and navigate to Editor | Live templates.

    Live templates


  • In DataGrip, there is a set of code inspections that detect and correct anomalous code in your project before you compile it. The IDE can find and highlight various problems, locate dead code, find probable bugs, spelling problems, and improve the overall code structure.

    Inspections can scan your code in all project files, or only in specific scopes (for example, only in production code, or in modified files).

    Every inspection has a severity level — the extent to which a problem can affect your code. Severities are highlighted differently in the editor so that you can quickly distinguish between critical problems and less important things. DataGrip comes with a set of predefined severity levels and enables you to create your own.

    To see the list of inspections, open settings Ctrl+Alt+S and navigate to Editor | Inspections. Disable some of them, or enable others, plus adjust the severity of each inspection. You decide whether it should be considered an error or just a warning.

    For example, the Redundant code in COALESCE call inspection reports all the arguments except for the first expression that does not evaluate to NULL.

    Redundant code in the COALESCE call

Intention actions

As you work in the editor, DataGrip analyzes your code, searches for ways to optimize it, and detects potential and actual problems.

As soon as the IDE finds a way to alter your code, it displays a yellow bulb icon yellow bulb icon in the editor next to the current line. By clicking this icon, you can view intention actions available in the current context. Intention actions cover a wide range of situations from warnings to optimization suggestions. You can view the full list of intentions and customize them in the Settings/Preferences dialog Ctrl+Alt+S.

To see the list of intention actions, open settings Ctrl+Alt+S and navigate to Editor | Intentions.

  1. Click the light bulb icon (or press Alt+Enter) to open the list of suggestions.

  2. Select an action from the list and press Enter.

    For example, you can use an intention action in the INSERT statement to create a table with valid field types:

    Inject a language with the intention action

Video tutorials

This video covers various topics about DataGrip. The video length is 40 minutes but you can click time codes on the Youtube page to see the topic that you are interested in. For more information about time codes and topics, see the description section at

Last modified: 06 August 2021