Switching PostgreSQL database or Schema in DataGrip JetBrains

此生再无相见时 提交于 2019-12-22 09:51:05

问题


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.


回答1:


If you speaking about the code, use SET search_path TO my_schema, public;

If you speaking about the tool, DataGrip, use switcher:




回答2:


  • 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

  1. You can delete the disused consoles as follows:

    1. Files (Right side panel of the IDE) >
    2. Scratches and Consoles >
    3. Database Consoles >
    4. Select the directory PostgreSQL - @localhost (Name of Project Data Source) >
    5. Delete disused consoles with right click and delete.
  2. Select a database to perform sql queries:

    1. Database (Left side panel of the IDE) >
    2. Double Click on PostgreSQL - @localhost >
    3. Double Click on the name of the database >
    4. Right click on public schema >
    5. New >
    6. Console

In this way in the directory Files> Scratches and Consoles > Database Consoles > PostgreSQL - @localhost, a new console positioned in said database was added.

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



来源:https://stackoverflow.com/questions/48891255/switching-postgresql-database-or-schema-in-datagrip-jetbrains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!