Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching PostgreSQL database or Schema in DataGrip JetBrains

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.

like image 961
Hamza Benzaoui Avatar asked Feb 20 '18 17:02

Hamza Benzaoui


People also ask

How do I switch to PostgreSQL database?

We can switch between the databases in PostgreSQL using \c or \connect metacommand, which creates a new connection and closes the current one.

Is schema and database same in PostgreSQL?

The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable . Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database they are connected to, if they have privileges to do so.

What's the difference between a PSQL database and a schema?

1. A database in PostgreSQL contains the subset of schema. It contains all the schemas, records, and constraints for tables. A Schema in PostgreSQL is basically a namespace that contains all the named database objects like tables, indexes, data types, functions, stored procedures, etc.


1 Answers

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

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

enter image description here

like image 87
moscas Avatar answered Sep 19 '22 11:09

moscas