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.
When you open DataGrip, you see the Welcome screen with project creating and opening options. From this screen, you can create a new project, open an existing project, or clone files from a Version Control System (VCS).
Project
Project is a complex of your data sources, scratch files, and attached directories. For more information about projects, refer to the DataGrip projects section.
Let us create the first_project project.
Creating a project
In the Welcome screen, click New Project.
In the New Project dialog that opens, type first_project in the Enter new project name or path field.
Click OK to create the project.
Once you create a new project, DataGrip opens it in a main window with the Database Explorer and Filestool windows opened:
Tool windows
Tool windows provide access to development tasks: viewing your database structure, running your scripts, working with version control systems and other external tools, performing code analysis, search, navigation, and so on.
For more information about arranging tool windows and using them in your tasks, refer to the Tool windows section.
Now you can set up a connection configuration for your database.
Step 2. Create a data source
Depending on a database vendor (MySQL, PostgreSQL, Oracle, and so on), you need to create a corresponding data source to use it to connect to the database.
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 Explorer, and change the driver for your connection.
Find more information about data sources in Data sources.
In this tutorial, you will set up a demo data source and connect to a demo database. To do this, you can either use the PostgreSQL or MySQL sample databases deployed remotely or download and use the SQLite sample database file.
You can also set up this demo data source using the connection credentials of a database you have setup and running somewhere else. To do this and connect to your database, enter the credentials or its JDBC URL in the corresponding fields of Data Source and Drivers dialog that is described in this tutorial.
PostgreSQL
MySQL
SQLite
In DataGrip, go to Database Explorer (View | Tool Windows | Database Explorer or ) .
Click the Create data source link.
Navigate to Data Source and select PostgreSQL.
DataGrip will open a Data Source and Drivers dialog with the settings of your new data source.
In DataGrip, go to Database Explorer (View | Tool Windows | Database Explorer or ) .
Click the Create data source link.
Navigate to Data Source and select MySQL.
DataGrip will open a Data Source and Drivers dialog with the settings of your new data source.
Prepare the SQLite sample database file by downloading from a GitHub repository, then copy the downloaded file to clipboard.
In DataGrip, paste the SQLite database file to the IDE project root directory.
To do that, in the Files tool window (View | Tool Windows | Files or Alt02) , click any area and press Ctrl0V. In the Copy dialog that appears, click OK.
Go to Database Explorer (View | Tool Windows | Database Explorer or ) .
Click the Create data source link.
Navigate to Data Source and select SQLite.
DataGrip will open a Data Source and Drivers dialog with the settings of your new data source.
Then, set up your new data source with the connection settings of your database.
PostgreSQL
MySQL
SQLite
In the Name field of the dialog, enter your new data source's name. For example, Demo DB.
If there is a Download missing driver files link at the bottom of the connection settings area, click it to download the JDBC driver.
In the Host field, enter the following server address:
postgresql.datagrip-dbs.intellij.net
Make sure that the Port field contains the PostgreSQL default value: 5432.
In the User field, enter the demo user name: datagrip.
In the Password field, enter the password: datagrip.
In the Database field, enter the database name: datagrip.
To make sure that the connection can be successfully established, click the Test Connection link at the bottom of the connection details area.
In the Schemas tab, make sure that the datagrip database that you will work with is selected.
Click OK to create the data source.
Once the data source is created, it appears in the Database Explorer.
In the Name field of the dialog, enter your new data source's name. For example, Demo DB.
If there is a Download missing driver files link at the bottom of the connection settings area, click it to download the JDBC driver.
In the Host field, enter the following server address:
mysql.datagrip-dbs.intellij.net
Make sure that the Port field contains the MySQL default value: 3306.
In the User field, enter the demo user name: datagrip.
In the Password field, enter the password: datagrip.
In the Database field, enter the database name: datagrip.
To make sure that the connection can be successfully established, click the Test Connection link at the bottom of the connection details area.
In the Schemas tab, make sure that the datagrip database that you will work with is selected.
Click OK to create the data source.
Once the data source is created, it appears in the Database Explorer.
In the Name field of the dialog, enter your new data source's name. For example, Demo DB.
If there is a Download missing driver files link at the bottom of the connection settings area, click it to download the JDBC driver.
In the File field, enter the path to your database file in the project root: demo_db.sqlite.
ALternatively, click Open and navigate to the file.
To make sure that the connection can be successfully established, click the Test Connection link at the bottom of the connection details area.
In the Schemas tab, make sure that the main database that you will work with is selected.
Click OK to create the data source.
Once the data source is created, it appears in the Database Explorer.
Step 3. Write and run SQL queries
In DataGrip, you can write SQL and NoSQL code in query consoles that are attached to data sources. When you create a new data source, the IDE creates a default query console for that data source.
Query console
Query consoles are SQL files in which you can compose and execute SQL statements. Unlike the usual SQL files, they are attached to your data source by default.
For more information about query consoles, refer to the Query consoles topic.
In this tutorial, we will run simple queries in the default query console that DataGrip creates and opens upon the new data source creation.
PostgreSQL
MySQL
SQLite
tip
In case you have closed the default query console, open it. To do that, in the Database Explorer, select your data source, click Jump to Query Console on the toolbar, then select Default Query Console.
In the default query console, enter the following SQL query:
SELECT*FROM actor;
To run the query, click Execute on the editor toolbar.
DataGrip will run the query and display query result set in the data editor tab of Services tool window (View | Tool Windows | Services or Alt08) for you to analyze.
At this step, no schema is selected as the current one in the <schema> dropdown on the console toolbar. However, the query can still be executed because DataGrip will use the default schema of the data source.
For more information about how to set a default schema, refer to the Schemas topic.
tip
In case you have closed the default query console, open it. To do that, in the Database Explorer, select your data source, click Jump to Query Console on the toolbar, then select Default Query Console.
In the default query console, enter the following SQL query:
SELECT*FROM actor;
To run the query, click Execute on the editor toolbar.
DataGrip will run the query and display query result set in the data editor tab of Services tool window (View | Tool Windows | Services or Alt08) for you to analyze.
At this step, no schema is selected as the current one in the <schema> dropdown on the console toolbar. However, the query can still be executed because DataGrip will use the default schema of the data source.
For more information about how to set a default schema, refer to the Schemas topic.
tip
In case you have closed the default query console, open it. To do that, in the Database Explorer, select your data source, click Jump to Query Console on the toolbar, then select Default Query Console.
In the default query console, enter the following SQL query:
SELECT*FROM actor;
To run the query, click Execute on the editor toolbar.
DataGrip will run the query and display query result set in the data editor tab of Services tool window (View | Tool Windows | Services or Alt08) for you to analyze.
At this step, no schema is selected as the current one in the <schema> dropdown on the console toolbar. However, the query can still be executed because DataGrip will use the default schema of the data source.
For more information about how to set a default schema, refer to the Schemas topic.
Step 4. Explore the database
Now you can explore your database and database objects in a tree view and also open the objects to view their data. In DataGrip, you can do this in Database Explorer.
Database Explorer
Database Explorer is a tool window that displays the database structure as a tree with nodes. You can create folders and move data sources to them, assign colors to data sources, filter the database objects, and so on.
For example, let us navigate to the actor table and its columns.
PostgreSQL
MySQL
SQLite
In the Database Explorer () , double-click the Demo_DB data source name to expand the list of introspected databases.
Then, double-click the nodes or click the arrow icon near them to expand the list of items: datagrip | public | tables | actor | columns.
To view the actor table data, double-click its name.
DataGrip will open the actor table in a data editor tab.
In the Database Explorer () , double-click the Demo_DB data source name to expand the list of introspected schemas.
Then, double-click the nodes or click the arrow icon near them to expand the list of items: datagrip | tables | actor | columns.
To view the actor table data, double-click its name.
DataGrip will open the actor table in a data editor tab.
In the Database Explorer () , double-click the Demo_DB data source name to expand the list of introspected . schemas
Then, double-click the nodes or click the arrow icon near them to expand the list of items: main | tables | actor | columns.
To view the actor table data, double-click its name.
DataGrip will open the actor table in a data editor tab.
Step 5. View, sort, and filter the data
In DataGrip, you can view and edit the data of database tables and views in the data editor and viewer.
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 this tutorial, we will sort the first_name column of actor table alphabetically and will also filter the last_name column to see the last names that start with JO.
PostgreSQL
MySQL
SQLite
To sort the data, in the data editor tab, click the arrows icon in the first_name column header. DataGrip will send the ORDER BY query to the database and display its result in the editor.
For more information about sorting data on the database side and on the client side, refer to the Sort data topic.
To filter the data, in the data editor tab, click Local Filter in the last_name column header. Enter JO in the search field and select the Value checkbox, then click any area in the data editor.
DataGrip will filter the data and display the result.
For more information about filtering data in the IDE, refer to the Filter data topic.
To sort the data, in the data editor tab, click the arrows icon in the first_name column header. DataGrip will send the ORDER BY query to the database and display its result in the editor.
For more information about sorting data on the database side and on the client side, refer to the Sort data topic.
To filter the data, in the data editor tab, click Local Filter in the last_name column header. Enter JO in the search field and select the Value checkbox, then click any area in the data editor.
DataGrip will filter the data and display the result.
For more information about filtering data in the IDE, refer to the Filter data topic.
To sort the data, in the data editor tab, click the arrows icon in the first_name column header. DataGrip will send the ORDER BY query to the database and display its result in the editor.
For more information about sorting data on the database side and on the client side, refer to the Sort data topic.
To filter the data, in the data editor tab, click Local Filter in the last_name column header. Enter JO in the search field and select the Value checkbox, then click any area in the data editor.
DataGrip will filter the data and display the result.
For more information about filtering data in the IDE, refer to the Filter data topic.
Next steps
After going through this tutorial, you can create a connection configuration and connect to a database using its JDBC URL, explore the connected database, run SQL queries in query consoles, and view the query results. Also, you can view, sort, and filter database object data.
To learn more about the IDE, consider the following topics and sections:
Learn how to view diagrams of your databases and schemas.
Introduction video
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, refer to the description section at youtube.com.
note
In the video, the DataGrip user interface is Classic UI. Starting from version 2023.1, the New UI is available. For more information about the New UI, refer to the corresponding topic.