2. Connecting to the PostgreSQL server
You’ve got two options here:
- Use the built-in feature from your IDE
- Use the Database Navigator plugin for Community editions
Connecting to PostgreSQL via WebStorm
The connection process is pretty much the same for other IDEs too.
- Open the "Database" panel. If you don’t see it, open it from the menu
View → Tool Windows → Database.
- On the
Databasepanel, click+and in the dropdown menu pickData Source → PostgreSQL.
- Set up your connection parameters:
- If this is your first time connecting to PostgreSQL, the IDE will prompt you to download the required driver.
Name: give your connection a name.Host: server address (usuallylocalhostfor a local install).Port: default port is5432.User: username (for example,postgres).Password: your user’s password. You can choose to save the password if you want.
- Hit the
Test Connectionbutton. If it works, you’ll see a green checkmark and the PostgreSQL version.
- If the test was successful, click
Applyand thenOK.
After saving the connection, you might see a notification from the IDE suggesting you set up the SQL dialect for your project or files. Click the configure link in that notification. You can always get back to these settings later via: Settings → Languages & Frameworks → SQL Dialects
In the SQL Dialects window that pops up, pick PostgreSQL. These settings are important for proper syntax highlighting, autocomplete, and SQL code analysis.
Your new connection will show up in the Database panel. You can expand it to see the list of databases, schemas, and tables (we only have public for now). Now you can open the SQL console to run queries or double-click tables to view their data.
Once you’re connected, you can run a test command to make sure everything’s working.
-- Check the version of the PostgreSQL server you’re connected to
SELECT version();
You can read more about all the settings in the JetBrains docs.
Connecting to PostgreSQL via Database Navigator
- Open the plugin panel: On the IDE sidebar, find and open the
DB Browsertab. If it’s not there, you can open it from the menuMain menu → DB Navigator. - Create a new connection. On the
DB Browserpanel, click the plus icon (+) and in the dropdown pickPostgreSQL.
- Fill in the connection details:
Name: come up with a name for this connection (postgres@localhost).Host: if PostgreSQL is installed on your computer, uselocalhost.Port: default port for PostgreSQL is5432.User: username for DB access (oftenpostgresby default).Password: password for this user.
- After entering the details, hit the
Test Connectionbutton. You should see a message about a successful connection. - If the test was successful, click
Applyand thenOKto save the settings.
Result:
After saving, your new connection will show up in the list on the DB Browser panel. Now you can expand it to see the database structure, available schemas, tables, and their columns. You’re ready to run your first SQL queries.
Once you’re connected, you can run a test command.
-- Check the version of the PostgreSQL server you’re connected to
SELECT version();
3. Writing simple queries in the Query Console
You can write queries even without a database. For example:
SELECT version();SELECT 2+2*2SELECT NOW()SELECT LENGTH('MAY')
4. Creating a database
Run the following SQL query:
CREATE DATABASE university;
You’ll see a confirmation CREATE DATABASE if the database was created successfully.
This short message might seem a bit dry, but trust me, it’s music to a programmer’s ears.
Now we’ve got a database called university.

GO TO FULL VERSION