How do I change the default schema in DataGrip?

Completed

The help article on schemas talks about changing the default for the session but I cannot find how to change the default for the server. Even in the screen shots on the help page you can see "(Default schema) in light grey text next to the name, but there's no way to change it!

0
9 comments

I found the answer just after posting this question, from this question/answer by Brandt Elison (thanks!) : Cannot change the default schema from guest to dbo MS SQL

When you set a database on the "Data Sources | General" tab it becomes the "default" database. It would be nice if the documentation mentioned this! :)

0

Click the <schema> list and select the schema that you need. Select a data source that you want to modify. On the General tab in the Database field, type the name of a schema that you want to use as default.

mybpcreditcard

0

I have also same error have any solution for that.

 

 

OneVanilla

0

Alievserega17 Thanks, I discovered the answer not long after posting my question.

Chanelnicoleyu97 See my answer and the answer from Alievserega17 for the solution.

0

Thanks a lot @Anthony for solutions i was facing same issue past few days finally now issue resolved .

OneVanilla

 

0

but using Database field in DataSource config page - you make this database to default for all databases under datasource. and when you make some changes in table-view - the request for update will use that database, not the current database you connected to.

in old DataGrip there is no problem with this, why they changed it, can't understand

0

Agroghkov,

Could you share your SQL and IDE logs since it works fine for me. IDE correctly switches between schemas.


 

Make sure you set Switch schema to Automatic

0

Thank you for sharing this information..

0

I can't get it to change for an existing datasource, but it works for a new one. Very weird.

This is for PostgreSQL.

The docs (https://www.jetbrains.com/help/datagrip/schemas.html#selecting_schema) for setting on the connection level don't seem to work.

It's annoying, as opening a new Query Console will default back to the default database and no schema, or `postgres` for my initial datasource.

I've got my Schema Pattern set as `hello:world`, but it still sets the default as public.

 

edit:

It seems if you have a schema that isn't public, you might need to do this:

```sql
ALTER DATABASE hello SET search_path TO world;
```

It then shows the hello.<schema> on new query console..

 

and querying does switch schema, if set to automatic:

world is now the default:

0

Please sign in to leave a comment.