Is it possible to share the query console between different datasources?


I have some queries and would like to execute them against dev/production database. If I'm changing the query, I'm duplicating the same one for dev and one prod. I'm just wondering if its possible to have one console and change the datasource connection.



If you right clicked on Datasource and selected "console" it will be mapped to that Datasource and couldn't be changed. You may use "Database Script" run configuration or create .sql script and select Datasource while execution.


Create a symlink to a console file of production database in the directory of dev database, works as expected


I was also wondering how to reuse console scripts. I found out, that when I create sql as scratch file, than I can change console/connection. I have not found how to access it from database tool window yet. But still I can get it by browsing Project structure under Scratches, or by ctrl+shift+n and typing its name.


sqlkng, could you please describe more precisely what result you want to achieve?
Via Database toolwindow, you can access only consoles, but you can drag and drop your scratch file from Scratches to Database Consoles/<database connection name> to use the file as a console.


Olga Mulina , I was trying to achieve same thing as Raviteja Gubba described in subject. However console is bound to database connection - this is by design. In case I wanted to run same query on different environment, I had to copy/paste into that environment connection console piece of code. To avoid this copy/paste divergency, it is better to have query in scratch sql file and if necessary, than change environment/connection.


sqlkng, my colleague Yaroslav has already suggested the solution in this message. Isn't it suitable for your case? 


Please sign in to leave a comment.