Setting current database schema

Answered

Running an .sql file generated by mysqldump, I can select the data source to be run on. So far, so good. However, there's no obvious option to select the desired schema. Instead, it will always use the Current schema to import the data into. Issuing "use other_db_name" manually in an IntelliJ database console didn't have any effect, neither.

Having clicked through virtually all of IntelliJ and Google, I ended up here asking: how can I switch the Current schema?

0
4 comments
Avatar
Permanently deleted user

@Serge Thank you for your immediate reply!

Unfortunately, setting the .sql file's SQL resolution scope to the desired schema didn't have any effect: upon running the file, IntelliJ executed all queries against the current schema thereby ignoring the scope set. I even had to manually select a data source as well despite the setting.

Even if this had worked out, the whole process of going to settings and setting a scope for a non-project file and a one-off operation would've been quite cumbersome to say the least.

Any other IDEA on how to query an sql file against an explicitly selected schema?

0

>Any other IDEA on how to query an sql file against an explicitly selected schema?

See this comment for the logic:

>you have connection (console, sql file attached to console) -> first trying to resolve to current schema from connection, than resolving as no connection

So once you have connected the sql file to the data source the current shema of the data source will be used. You can either change the current schema for the data source to the desired one or issue "use other_db_name" on file to switch to needed schema.

 

 

0
Avatar
Permanently deleted user

The current database is the one configured in your connection properties.

In case you are still looking, or to whomever finds his way here through google, the current database is the one configured in your connection (a.k.a. the one you are connected to). Even though the same db user may have privileges on other databases, phpstorm only uses the connected one for auto completion etc.

Just right click on your db connection > properties. There fill the desired "current database" as database name and reconnect.

2

Please sign in to leave a comment.