Does anybody know how to switch between PostgreSQL databases or schemas in DataGrip (The Database IDE from JetBrains) in the console?
i can do that in Mysql by using:
Use my_database;
I tried using the Psql methods like
\connect
or
\c
but nothing works.
And could not find anyting in DataGrip Help page.
If you speaking about the code, use SET search_path TO my_schema, public;
If you speaking about the tool, DataGrip, use switcher:
- Client: DataGrip
- Database engine: PostgreSQL
To change the use of a database, you can do it by:
- From the Terminal (IDE or SO) with psql
- Through UI with pgAdmin4 (Query Tool) or IDE
Change the database through UI with the IDE
You can delete the disused consoles as follows:
- Files (Right side panel of the IDE) >
- Scratches and Consoles >
- Database Consoles >
- Select the directory PostgreSQL - @localhost (Name of Project Data Source) >
- Delete disused consoles with right click and delete.
Select a database to perform sql queries:
- Database (Left side panel of the IDE) >
- Double Click on PostgreSQL - @localhost >
- Double Click on the name of the database >
- Right click on
public schema
>
- New >
- Console
In this way in the directory Files> Scratches and Consoles > Database Consoles > PostgreSQL - @localhost, a new console positioned in said database was added.
Finally, you can operate with DDL (create, alter, drop) or DML (insert, update, delete, select).
CREATE TABLE test_2 (test int);
TABLE test_2;
Quick tip: With the cursor positioned within the source code and ctrl+enter the sql queries are executed in the IDE.
GL